K
kerravon
According to 6.8 of C90, #if takes a constant expression.
According to 6.4 of C90, the sizeof operator is part of a constant
expression.
Why then do most of my compilers barf on this?
#include <stdio.h>
#if sizeof(int) >= 4
#define XXX "big"
#else
#define XXX "small"
#endif
int main(void)
{
printf("hello %s\n", XXX);
return (0);
}
They barf on the "#if sizeof ..." line.
They explicitly say that I can't use sizeof in a #if
So which bit of the standard did I miss?
BFN. Paul.
According to 6.4 of C90, the sizeof operator is part of a constant
expression.
Why then do most of my compilers barf on this?
#include <stdio.h>
#if sizeof(int) >= 4
#define XXX "big"
#else
#define XXX "small"
#endif
int main(void)
{
printf("hello %s\n", XXX);
return (0);
}
They barf on the "#if sizeof ..." line.
They explicitly say that I can't use sizeof in a #if
So which bit of the standard did I miss?
BFN. Paul.