Undelivered mail

MAILER%ALASKA.BITNET at CUNYVM.CUNY.EDU MAILER%ALASKA.BITNET at CUNYVM.CUNY.EDU
Sat Mar 12 15:19:28 AEST 1988


Subject:  Re: Header problems

[Non-Deliverable:  User does not exist or has never logged on]

Reply-To: Info-C at BRL.ARPA

Received: From UWAVM(MAILER) by ALASKA with Jnet id 6493
          for SXJVK at ALASKA; Fri, 11 Mar 88 19:48 AST
Received: by UWAVM (Mailer X1.25) id 4373; Fri, 11 Mar 88 20:47:33 PST
Date:         Wed, 9 Mar 88 23:59:49 GMT
Reply-To:     Info-C at BRL.ARPA
Sender:       Info-C List <INFO-C at NDSUVM1>
From:         Pablo Halpern <pablo at polygen.uucp>
Subject:      Re: Header problems
Comments: To: info-c at brl-smoke.arpa
To:           Vic Kapella <SXJVK at ALASKA>

>From article <3351 at chinet.UUCP>, by dag at chinet.UUCP (Daniel A. Glasser):
>            A better way to do it, in each place you want to define NULL,
> is:
>
>     #ifndef    NULL
>     #define    NULL    ((void *)0)
>     #endif
>
> On older compilers, replace 'void' with 'char'.  This allows the use of
> a short NULL representation when the compiler is smart enough to use it
> but forces passing of NULL in argument lists as a pointer sized object.

Do NOT replace 'void' with 'char' for old compilers unless you are prepared
to cast every use of NULL to the pointer type you are assigning (or comparing,
etc.).  Most compilers will complain of a pointer type missmatch since
(char *) doesn't match (int *) or (struct foo *) etc..  I agree that for
ANSI compilers, the above is correct, since (void *) DOES match (int *)
by definition.  For compilers that don't support (void *), you must have
a compiler-specific definition of NULL:

    #define NULL 0        /* If sizeof(int) == sizeof(char *) */

or

    #define NULL 0L        /* if sizeof(long) == sizeof(char *) */

This avoids pointer type missmatches because all compilers let you compare
any pointer agains integer zero.  Since the above #defines
are necessarily machine (and compiler) specific, I put these
types of declarations in a file called "machine.h" which contains machine
and compiler-dependent declarations and is different for each compiler I
use.  "machine.h" is #include'd in all of my source files.

Pablo Halpern        mit-eddie \
Polygen Corp.        princeton  \ polygen!pablo
200 Fifth Ave.        bu-cs       /
Waltham, MA  02254    stellar   /



More information about the Comp.lang.c mailing list