This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Possible variadic macro bug


In message <20011109223634.A22409@daikokuya.demon.co.uk>, Neil Booth writes:
>Peter Seebach wrote:-
>
>> These macros should, IMHO, do the same thing:
>> 
>> #define panic(x,...) _panic(x, __FILE__ , __LINE__ , ## __VA_ARGS__)
>> #define panic(x,...) _panic(x, __FILE__ , __LINE__, ## __VA_ARGS__)
>
>They do in 3.0.  But have you read the 2.95.3 manual?  You would see
>there that, in that version, this use of ## is whitespace-sensitive
>(daft for what is supposed to be a tokenized preprocessor, I know).

Oops.  :)  I read about the usage elsewhere, and didn't check the older
manual (since I was looking at the newer one for comparisons with the
ISO C stuff).

>> While I'm at it, the documentation for ISO's __VA_ARGS__ in extend.texi
>> is misleading.  While it's true that, given
>> 	#define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
>> you can't omit the comma, you *could* write
>> 	#define debug(format ...) fprintf(stderr, format __VA_ARGS__)
>> in C99, and then the comma is optional.  (See 6.10.3, paragraph 10, for
>> the description.)

>Have you tried it?

I'm just saying it's correct ISO C99.  I haven't tried it, because I don't
have an ISO C99 compiler.  :)  It would be good for the docs to show how
to do this using the C99 varargs macro stuff, though; as is, it sounds like
they're saying you *can't* do that in the ISO C stuff.

-s


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]