[Freeciv-Dev] Re: (PR#6223) improved die()
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] Re: (PR#6223) improved die() |
From: |
"Per I. Mathisen" <per@xxxxxxxxxxx> |
Date: |
Sun, 21 Sep 2003 21:59:49 -0700 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
On Sun, 21 Sep 2003, Jason Short wrote:
> > This improves the die() call so that file and line where die() was called
> > is printed on exit. This is very useful for debugging and bug reports. I
> > hope the use of variadic macros is portable. I think they are C99 safe, at
> > least.
>
> This ... functionality in a macro is not standard C.See freelog() for
> how to do it for gcc only.
Is too.
Quoth gcc manual:
"In the ISO C standard of 1999, a macro can be declared to accept a
variable number of arguments much as a function can. The syntax for
defining the macro is similar to that of a function. Here is an example:
#define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
Here ... is a variable argument. In the invocation of such a macro, it
represents the zero or more tokens until the closing parenthesis that ends
the invocation, including any commas. This set of tokens replaces the
identifier __VA_ARGS__ in the macro body wherever it appears. See the CPP
manual for more information.
GCC has long supported variadic macros, and used a different syntax that
allowed you to give a name to the variable arguments just like any other
argument. Here is an example:
#define debug(format, args...) fprintf (stderr, format, args)
This is in all ways equivalent to the ISO C example above, but arguably
more readable and descriptive."
So the way freelog does variadic macros is gcc only, while the way I did
them is C99. If we add a gcc check here, this functionality will be absent
from all C99 conforming compilers but gcc.
What compilers are freeciv compiled with on Amiga and VMS, BTW?
- Per
[Freeciv-Dev] Re: (PR#6223) improved die(), Ilkka Lehtoranta, 2003/09/23
|
|