[GRASS5] Re: Automatic gettextizations ; tables and g.html2man

Glynn Clements glynn at gclements.plus.com
Sun Mar 13 18:43:20 EST 2005


Daniel Calvelo Aros wrote:

> Mmmmh... Would it make sense to have a G_debug macro/function (in gis.h? not
> sure...) to help in that? I was thinking of something like providing
> 
> #define G_debug(msg)\
> #ifdef DEBUG\
> fprintf(stderr,"[%s:%s] ",__FILE__, __LINE__);\
> #ifdef __GNUC__\
> fprintf(stderr,"in %s : ", __FUNCTION__);\
> #endif\
> fprintf(stderr, ##msg );\
> #endif

Including preprocessor directives in a macro definition isn't valid
ANSI C; you would need to move the #define into each branch of the
conditional, e.g.:

#ifdef DEBUG
# ifdef __GNUC__
#  define G_debug(msg) fprintf(stderr,"[%s:%s] in %s : %s\n",__FILE__, __LINE__, __FUNCTION__, (msg))
# else
#  define G_debug(msg) fprintf(stderr,"[%s:%s] : %s\n",__FILE__, __LINE__, (msg))
# endif
#endif

But the general idea of using __FILE__ etc is sound.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list