Sheldon Hearn wrote:
> What I really want is a static inline void function declared in a header
> file and included in various source files, looking something like this:
>
> static inline void
[ ... ]
> GCC gives "syntax error before 'void'". Fair enough.
>
> So obviously, this should be implemented as a macro.
Not so obvious. The warning should have been the first clue.
> But GCC warns that
> ANSI C doesn't support variable arguments to macros. Fine.
#define VARRADIC macro(x) foo x
...
macro((a, b, c, ...));
/* x:=(a, b, c, ...), so macro(x) expands to foo(a, b, c, ...)*/
> So I give up on any semblence of efficiency and settle for a real
> wrapper. This is where things get interesting. The stdarg(3) manual
> page says this:
>
> Unlike the varargs macros, the stdarg macros do not permit programmers to
> code a function with no fixed arguments. This problem generates work
> mainly when converting varargs code to stdarg code, but it also creates
> difficulties for variadic functions that wish to pass all of their argu
> ments on to a function that takes a va_list argument, such as
> vfprintf(3).
>
> This shouldn't apply to what I'm trying to do, because I have one fixed
> argument.
It doesn't. I've often thought cdefs.h needed varradic K&R
vs. ANSI wrappers. I've submitted them once or twice... they
really clean up the code.
[ ... other stuff related to K&R vs. ANSI varradic functions ... ]
> So, um, what the fsck is going on here? :-)
Well, first, "inline" should really be "__inline"; that's the
"error before 'void'" that gcc is complaining about. There
are other ways to skin this cat in gcc, including using some
"__attribute__" qualifier, or whatever. Try grep'ing through
/usr/include/sys/*.h for "inline".
Second, questions like this really belong on -questions... or
even one of the C language or gcc mailing lists... ;-).
-- Terry
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message