On Thu, 2012-05-03 at 07:22 -0300, Mauro Carvalho Chehab wrote:
> Em 02-05-2012 21:42, Andy Walls escreveu:
> > On Wed, 2012-05-02 at 19:17 -0300, Mauro Carvalho Chehab wrote:
> >> I suspect that sizeof() won't work inside a macro.
> >
> > sizeof() is evaluated at compile time, after preprocessing.
> > It should work inside of a macro.
>
> I tried to compile this small piece of code:
>
> enum foo { BAR };
> #if sizeof(foo) != sizeof(int)
> void main(void) { printf("different sizes\n"); }
> #else
> void main(void) { printf("same size\n"); }
> #endif
Oh, I misunderstood what you intended when you said "work inside a
macro".
You are correct. I would not expect sizeof() to work in a condition
evaluated by the preprocessor. Only the compiler can properly compute
sizeof(), after the preprocessor has done it's work -- unless someone
builds a much smarter, multiple-pass preprocessor.
> > See the ARRAY_SIZE() macro in include/linux/kernel.h for a well tested
> > example.
>
> ARRAY_SIZE() doesn't have an #if on it.
Correct. My example is irrelevant, because I didn't understand what you
meant.
Sorry for the noise.
Regards,
Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html