directive #if and operator sizeof

Started by andi.martin, December 17, 2008, 07:26:36 PM

Previous topic - Next topic

andi.martin

Hi,

AFAIK the sizeof operator returns a constant expression (integer type).
So why
#if sizeof(char)==1
emits a compiler error..?

Regards,
Andreas Martin

JohnF

Quote from: andi.martin on December 17, 2008, 07:26:36 PM
Hi,

AFAIK the sizeof operator returns a constant expression (integer type).
So why
#if sizeof(char)==1
emits a compiler error..?

Regards,
Andreas Martin

I would imagine that using it in a pre-processing context is disallowed.

John

pgoh

John is correct. sizeof is evaluated at compile time, while the preprocessor is evaluated before compilation.