prototypes, NULL, and magic

Doug Gwyn gwyn at smoke.brl.mil
Wed Apr 3 08:06:27 AEST 1991


In article <1561 at sheol.UUCP> throopw at sheol.UUCP (Wayne Throop) writes:
>So, specifically: under the upcoming BSD release, with prototypes in
>scope, is it really safe to use unadorned NULL to terminate a
>variable argument list a-la execl(2) family as Chris seemed to
>imply (but did not explicitly state)?  Or did I misunderstand?

No, that would depend on the implementation.  If NULL is defined as
0 (which is always allowed for a standard-conforming implementation),
there could easily be a problem.  The prototype does not specify the
types of the ,... arguments, so no automatic argument conversion
will be done for them.  If NULL is defined as ((void*)0), for
example, then it should work, only because void* and char* are
required to have the same representation (so if a char* is expected,
a void* can be passed for the actual argument).



More information about the Comp.lang.c mailing list