runtime 'sizeof()'?

ross m. greenberg greenber at acf4.UUCP
Mon Jan 28 09:16:00 AEST 1985


<>
What I always have is a little .h file:
= = = = = = = = = = =
#ifndef	NULL
#define	NULL	(int) 0
#endif

#ifndef NULLP
#define	NULLP	(char *)NULL
#endif
 = = = = = = = = = = =
Aside from being "portable", it really makes code easier to read because
you know which are apples and which are pears.

I also go the whole way with additional NULLs defined (NULLL, NULLS,
NULLD, NULLF, etc.), because this won't always work:

long	var;
	if (var == NULL)  {stuff}

Then of course the question is, will this work:

long	var;
	if (var) {stuff}

I've found that it doesn't always (flaky compilers!), so I have
made my code (when needed):

long	var;
	if (var != NULLL) {stuff}

Sloppy, but portable!!! (and easy to understand, even for me!)

Didn't we have this discussion about three months ago??


------------------------------------------------------
Ross M. Greenberg  @ NYU   ----> { allegra,ihnp4 }!cmcl2!acf4!greenber  <----



More information about the Comp.lang.c mailing list