By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

__VA_ARGS__

P: n/a
Hi,

I have a variadic macro:

#define throw(msg, ...) excep_throw(msg, __VA_ARGS__)
If i do: throw("Error", 0), it compiles ok.

If i do: throw("Error"), i get an error:

error: parse error before ')' token
I think it's because without the last parameter, the function is
called as: except_throw("Error", ). How do i get rid of this trailing
comma problem?

I'm using gcc-3.4.4.
void excep_throw(char *msg, ...)
{
...
}
Nov 14 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Russell Shaw wrote:
Hi,

I have a variadic macro:

#define throw(msg, ...) excep_throw(msg, __VA_ARGS__)
If i do: throw("Error", 0), it compiles ok.

If i do: throw("Error"), i get an error:

error: parse error before ')' token
I think it's because without the last parameter, the function is
called as: except_throw("Error", ). How do i get rid of this trailing
comma problem?

I'm using gcc-3.4.4.
void excep_throw(char *msg, ...)
{
...
}


Disregard, i figured it out. Always have one mandatory parameter
withing the va-args.
Nov 14 '05 #2

P: n/a
Russell Shaw <rjshawN_o@s_pam.netspace.net.au> wrote:
Hi, ? I have a variadic macro:

#define throw(msg, ...) excep_throw(msg, __VA_ARGS__)
If i do: throw("Error", 0), it compiles ok.

If i do: throw("Error"), i get an error:

error: parse error before ')' token
I think it's because without the last parameter, the function is
called as: except_throw("Error", ). How do i get rid of this trailing
comma problem?


#define throw(...) excep_throw(__VA_ARGS__)

Nov 14 '05 #3

P: n/a

Russell Shaw wrote:
Hi,

I have a variadic macro:

#define throw(msg, ...) excep_throw(msg, __VA_ARGS__)


Try

#define throw(msg, ...) excep_throw(msg, ##__VA_ARGS__)

-J. Hess

Nov 14 '05 #4

P: n/a
"James Hess" <my*****@gmail.com> writes:
Russell Shaw wrote:
I have a variadic macro:

#define throw(msg, ...) excep_throw(msg, __VA_ARGS__)


Try

#define throw(msg, ...) excep_throw(msg, ##__VA_ARGS__)


That solution is specific to GCC.
--
"...deficient support can be a virtue.
It keeps the amateurs off."
--Bjarne Stroustrup
Nov 14 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.