Date: Thu, 19 Jul 2001 00:16:13 -0700 From: Terry Lambert <tlambert2@mindspring.com> To: Sheldon Hearn <sheldonh@starjuice.net> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Weird <stdarg.h> problem in 4.3-STABLE Message-ID: <3B56893D.CBACD316@mindspring.com> References: <11254.995477648@axl.seasidesoftware.co.za>
next in thread | previous in thread | raw e-mail | index | archive | help
Sheldon Hearn wrote: > What I really want is a static inline void function declared in a heade= r > 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 =2E.. macro((a, b, c, ...)); /* x:=3D(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 programmer= s to > code a function with no fixed arguments. This problem generates work= > mainly when converting varargs code to stdarg code, but it also creat= es > difficulties for variadic functions that wish to pass all of their ar= gu=AD > 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 majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B56893D.CBACD316>