This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: inline (Re: guile: going the way of DEATH)


Hi!

>>>>> Greg Badros writes:

 >> The biggie is the DBUG macro--multiple macros of the same name
 >> that differ only in their number of arguments is not allowed.

 GB> Hmmm... we protect that one with #ifdef __GNUC__, though.  From
 GB> scwm.h:

This code is not portable:

/* Not GNUC, so no varargs macros */
#  ifdef SCWM_DEBUG_MSGS
#    define DBUG(x,y) scwm_msg(DBG,x,y)
#    define DBUG(x,y,a) scwm_msg(DBG,x,y,a)
#    define DBUG(x,y,a,b) scwm_msg(DBG,x,y,a,b)
#    define DBUG(x,y,a,b,c) scwm_msg(DBG,x,y,a,b,c)
#    define DBUG(x,y,a,b,c,d) scwm_msg(DBG,x,y,a,b,c,d)
#    define DBUG(x,y,a,b,c,d,e) scwm_msg(DBG,x,y,a,b,c,d,e)
#  else
#    define DBUG(x,y)
#    define DBUG(x,y,a)
#    define DBUG(x,y,a,b)
#    define DBUG(x,y,a,b,c)
#    define DBUG(x,y,a,b,c,d)
#    define DBUG(x,y,a,b,c,d,e)
#  endif

There are C preprocessors that can't cope with macros that differ only
in their signatures.

The only portable way to do macros with variadic arguments is the
following:

#define DBUG(args) (scwm_msg args)

then use it with doubled-parentheses, such as:

DBUG ((x,y,a,b,c));
DBUG ((x,y));

-- 
 Gordon Matzigkeit <gord@fig.org> //\ I'm a FIG (http://www.fig.org/)
    Lovers of freedom, unite!     \// I use GNU (http://www.gnu.org/)

Copyright (C) 1998 FIG.org; the creator offers you this gift and wants it
to remain free.  See http://www.fig.org/freedom.html for details.
  This work may be copied, modified and distributed under the GNU General
  Public License (GPL).  See http://www.gnu.org/copyleft/gpl.html.