[comp.lang.c] Variadic functions

chip@ateng.ateng.com (Chip Salzenberg) (11/13/88)

    WARNING -- NULL ALERT.
    If you understand NULL pointers, skip this article.

According to crossgl@ingr.UUCP (Gordon Cross):
>   Wouldn't it be much nicer to be able to call the
>   function with the single line
>
>        yourfunction ("arg1", "arg2", ... , 0);

Correct ways to code this function call would be:

	yourfunction ("arg1", "arg2", ... , (char *) 0);
or
	yourfunction ("arg1", "arg2", ... , (char *) NULL);

The reason?  Neither uncasted 0 nor uncasted NULL [1] is acceptable as an
actual function parameter of any pointer type.  (Except in the presence
of a function prototype, of course; but this is a variadic function
we're discussing, so prototypes are almost irrelevant.)

[1]   According to K&R and the dpANS, "#define NULL 0" is permitted.
-- 
Chip Salzenberg             <chip@ateng.com> or <uunet!ateng!chip>
A T Engineering             Me?  Speak for my company?  Surely you jest!
	   Beware of programmers carrying screwdrivers.