on the fringe of C syntax/semantics

roy at bonzo.sts.COM roy at bonzo.sts.COM
Wed Oct 4 11:10:00 AEST 1989


Here are a couple questions that come up in conjunction with using the
'varargs' series of function calls.  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?  You're not specifying a variable - it's only
a type.  I really am curious about what the semantics to the compiler
would be ...  The second question is in conjunction with how to
declare certain types.  Things like 'int' and 'char *' are a piece of
cake, but how about a good, general declaration for a function?
'(int *())' and '(int ())' were two tries at declaring a general function
that returns an 'int', but they didn't work.  Are you stuck with
something like '(int (*foo)())', where 'foo' is a particular function
or is there a better way to do this?  The only thing we've tried that
works is just to declare the type as 'char *'.  But that's ugly and
non-portable.  Any other ideas?


==================================================================
Roy Bixler                   | UUCP: ...!{claris,sun}!sts!roy    |
Semiconductor Test Solutions | Internet: roy at bonzo.sts.COM       |
4101 Burton Dr.              | phones: (408) 727-2885 x132 (work)|
Santa Clara, CA  95054	     |         (408) 289-1035      (home)|
==================================================================



More information about the Comp.lang.c mailing list