[Freeciv-Dev] C99 variadic arguments in macros
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Say we have some variadic arguments in a macro:
#define notify(pplayer, text, ...) \
if (diplomacy_verbose) { \
notify_player_ex(pplayer, -1, -1, E_DIPLOMACY, text, __VA_ARGS__); \
}
Oddly enough the __VA_ARGS__ is not the same as a va_list "variable",
but is actually the direct substition of '...'. So the above is correct
while
static void notify(struct player *pplayer, const char *text, ...)
{
if (diplomacy_verbose) {
va_list ap;
struct conn_list *dest = (struct conn_list*)&pplayer->connections;
va_start(ap, text);
vnotify_conn_ex(dest, -1, -1, E_DIPLOMACY, text, ap);
va_end(ap);
}
}
is the function form.
This can easily lead to confusion. But it seems the macro form would be
preferable for several reasons; the only drawback is that it requires C99.
jason
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] C99 variadic arguments in macros,
Jason Short <=
|
|