CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

#if and #error directive

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

#if and #error directive
PostPosted: Thu Dec 09, 2004 11:00 am     Reply with quote

Hello,

I am trying to achieve something like this:

#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

View user's profile Send private message

PostPosted: Thu Dec 09, 2004 5:14 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group