time pointer, hours and minutes

07 Nov 2010 . Edited: 07 Nov 2010


This line should return a const pointer to a tm structure, populated with the seconds count ( returned from the real time clock )

-    struct tm *t = localtime(&seconds);

and then I want to see if the time is 5 oclock.

-     if (t.tm_hour == 17 && t.tm_sec == 00 && enablealarm )

but the compiler throws two erroers on this line

"Expression must have class type (E153)" in file "/main.cpp"


either I have been in front of the PC too long this weekenmd or something else is wrong .......

Any ideas folks?


ok fixed it by doing this

struct tm t = *localtime(&seconds);


which then allows access to the contents.

Ahhh relearning C

17 Jan 2011

Dear Ian,

Thank you for the solution. I had the same problem and found your message via search: "E153".

 Regards, Rainer

17 Jan 2011

You could do instead:

if (t->tm_hour == 17 && t->tm_sec == 00 && enablealarm )

When you have a pointer to structure, you need to use -> to access its fields. Basically it's a shortcut for (*struc).field.