How to get system time?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Gnasty Gnork
Posts: 18
Joined: Fri Jun 20, 2014 12:12 pm

How to get system time?

Post by Gnasty Gnork »

Im trying to use:

Code: Select all

ITimer *real_time;
 
 
 
u32 system_hour = real_time->getRealTimeAndDate().Hour;

But this doesnt seem to work (compile errors). Is there a better/proper way to get system hour? Please help

Here is the error that i get, relative to real_time;
__vfptr CXX0030: Errore: impossibile valutare l'espressione

That means "Impossible to evaluate expression" or something like that.
CuteAlien
Admin
Posts: 9679
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to get system time?

Post by CuteAlien »

You have to get the timer from the IrrlichtDevice, in your case you only have an uninitialized pointer. But that's not the problem you have (you would notice that at runtime not compile-time). Not exactly sure about your errror - it also doesn't look complete. Is this really the whole error? (Please never try to shorten compiler errors, they are already as short as they can be without throwing out information others need to help you - just copy paste them full when asking for help)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Gnasty Gnork
Posts: 18
Joined: Fri Jun 20, 2014 12:12 pm

Re: How to get system time?

Post by Gnasty Gnork »

Yeah sorry im just dumb... Thank you for helping me opening my eyes.

Here is how it works (if somebody needs it):

Code: Select all

    ITimer *real_time = device->getTimer();
 
 
u32 system_hour = real_time->getRealTimeAndDate().Hour; 
Btw the full error was:

Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: How to get system time?

Post by hybrid »

Yeah, so first line (even no error here) indicates quite obviously that you access an uninitialized NULL pointer. Which you should never do.
Post Reply