Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2003:
[Freeciv-Dev] Re: (PR#6223) improved die()
Home

[Freeciv-Dev] Re: (PR#6223) improved die()

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#6223) improved die()
From: "Jason Short" <jshort@xxxxxxxxxxxxxx>
Date: Mon, 22 Sep 2003 19:11:11 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Mon, 22 Sep 2003, John Wheeler wrote:

>
> [per - Mon Sep 22 04:59:48 2003]:
>
> > 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.

Yes, it is part of C99.

> I think what Jason is refering to is this: (in log.h)
>
> #ifdef __GNUC__
> #define freelog(level, args...) do { \
> .
> .
> .
> #else
> /* non-GCC: */
> static void freelog(int level, const char *message, ...)
> {
> .
> .
> .
> }
> #endif /* __GNUC__ */
>
> If variadic macros are available for more than just GCC, then that
> probably should be a different define up top, say __C99__ or even
> __VARIADIC__ (which could be defined in shared.h in a "#ifdef
> GCC/#define __VARIADIC__ /#endif block).

We haven't decided to go fully C99, so something like this would be good.
Either a configure check for a C99 compiler (if such a thing is possible)
or something like __C99__ (if such a thing exists).

> (BTW, isn't it bad form to have function definitions in a .h file?
> Would moving void freelog(){} to log.c and wrapping it a "#ifndef
> freelog()" work?)

Well, the same #ifdef could be used as was in the header file (but
reversed).  It's done the way it is to be inline (and therefore faster),
even though officially freeciv doesn't use inline functions :-(.

jason



[Prev in Thread] Current Thread [Next in Thread]