|
-
Jan 14th, 2006, 08:45 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] sizeof
Could someone tell me why the following code doesn't work?
#if sizeof(int) > 1
//do something
#endif
When it's compiled it doesn't like the use of the sizeof operator and throws out an error... forgot what the error was, I did this at work.
I'm sure it must be something to do with the precedense of compilation but I can't find anything on the web that explains the failure.
I'm using a keil c166 compiler.
Any help, much appreciated.
-
Jan 14th, 2006, 11:48 AM
#2
New Member
Re: sizeof
You can only use integer constant expression there. sizeof(int) is determined at compile time, but the macros are parsed at pre-compile time. So it can't work.
CodeGuru Moderator & Article Reviewer
Differences of habit and language are nothing at all if our aims are identical and our hearts are open. - J.K. Rowling, HP and the Goblet of Fire
-
Jan 14th, 2006, 02:42 PM
#3
Thread Starter
Hyperactive Member
Re: sizeof
Sounds reasonable. Thought it must be something to do with the order of pre-processor/compiler. I'll just use a CompileAssert then. 
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|