This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

FW: Pointer woes... (int) 0 or (void *) 0 for NULL???


On Tuesday, March 10, 1998 4:24 PM, Mark Schaefer [SMTP:mschaefer@dsai.com] 
wrote:

> Seems like a real catch-22 to me, except that case 1 is written to the
> standard that
> " Because of standard conversions, 0 can be used as a constant of any
> integral, floating-point, pointer, or pointer-to-member type."
>
> Any help on this one?

It really sounds like NULL has not been defined as 0 even though you
think it has.

Repeat your tests with 0 substituded for NULL. Also, in the functions
where the problesms arise, add a diagnostic like:

	cout << "NULL is defined as " << STR(NULL) << endl;


Prior to this, add the following #define's somewhere:

	#define XSTR(X) #X
	#define STR(X) XSTR(X)

This ensures that STR(NULL) turns into a string literal containing
the replacement tokens for NULL.


Remember, in C and C++, you trigger undefined behavior if you
redefine a macro without #undef'ing it first! So if a NULL already
exists and you redefine it, anything may happen, including the
possibility that the old version prevails.

You may only redefine macros if you redefine them with the
exact same replacement text (including same whitespace
separation).



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]