-
[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.
-
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. ;)
-
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.