Moving to AMD64 bit and porting issues

Segher Boessenkool segher@kernel.crashing.org
Fri Nov 4 12:35:00 GMT 2005


>> Using NULL in this case is not portable; you *must*
>> use a cast to the exact pointer type that the
>> varargs function expects to see.  Different pointer
>> types can have different representation.
>
> However, it does seem that must platforms understand NULL and assigns
> the correct type.  I do agree that for portability we should use the
> cast.

Sure; with GCC, all targets (that I know of) use the same
representation (and ABI) for pointers to any data object.
This is not true for pointers to function, though.  So in
practice the code [with plain NULL instead of (type *)0]
will work fine; it is still not correct C code, though.

I thought we had a warning for this nowadays, btw?


Segher



More information about the Gcc-help mailing list