#if (sizeof(cfg)+sizeof(dia))>255 // if size of those 2 structs is greater than 255
#error eeprom full! // show the error
#endif
I get "expression must evaluate to a constant".
Does anyone know another way?
Thank you.
RossJ
Joined: 25 Aug 2004 Posts: 66
Posted: Thu Dec 09, 2004 5:14 pm
Your code works for me (compiled with PCWH 3.214 for a PIC18F2620). Are you sure cfg and dia are types and not just variables. You can't sizeof a variable, just its type. If you are creating structs, then you must use the typedef operator to declare a new type. Then do your sizeof with the type and declare your variables of the type. Also, make sure you have declared your types BEFORE trying to do a sizeof on it.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum