NO

Author Topic: directive #if and operator sizeof  (Read 3581 times)

andi.martin

  • Guest
directive #if and operator sizeof
« 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
« Last Edit: December 17, 2008, 10:05:59 PM by andi.martin »

JohnF

  • Guest
Re: directive #if and operator sizeof
« Reply #1 on: December 18, 2008, 08:38:41 AM »
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

  • Guest
Re: directive #if and operator sizeof
« Reply #2 on: December 18, 2008, 08:06:51 PM »
John is correct. sizeof is evaluated at compile time, while the preprocessor is evaluated before compilation.