on the fringe of C syntax/semantics

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Oct 5 06:51:09 AEST 1989


In article <80100001 at bonzo> roy at bonzo.sts.COM writes:
>When calling the va_arg() function, the 2nd parameter is supposed to be
>simply a type, such as int, char, char *, etc.  So, the first question
>is, how does it know what type you specified?

It doesn't work with all types, only those for which appending "*"
produces a type that is a valid pointer to the argument type.  Of
course the va_arg() MACRO (not function) does this by straightforward
macro expansion of the argument using a template where the expanded
argument is followed by a "*".

Sometimes you need to provide a typedef name, if the type is complex
enough.

>'(int *())' and '(int ())' were two tries at declaring a general function
>that returns an 'int', but they didn't work.

int (*)() is a valid type for a pointer to function (with unspecified
argument information) returning an int value.



More information about the Comp.lang.c mailing list