Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!prls!pyramid!decwrl!sun!david From: david@sun.uucp (David DiGiacomo) Newsgroups: net.lang.c Subject: Re: What should be added to C, call Message-ID: <3926@sun.uucp> Date: Wed, 4-Jun-86 16:13:35 EDT Article-I.D.: sun.3926 Posted: Wed Jun 4 16:13:35 1986 Date-Received: Fri, 6-Jun-86 04:49:37 EDT References: <36@mit-prep.ARPA> <2600062@ccvaxa> Organization: Sun Microsystems, Inc. Lines: 24 In article <2600062@ccvaxa> aglew@ccvaxa.UUCP (Andy "Krazy" Glew) writes: >Sorry, backslashes don't help macros that I want to have conditional >sections of code in. Eg. I can't do > >#define debugf(parmlist) \ >#ifdef DEBUG \ > printf parmlist \ >#else \ > /* nothing */ \ >#endif There is a simple way to do this if you are willing to define one extra macro for each condition you want to test within a macro definition. #define IFTRUE(a,b) a #define IFFALSE(a,b) b #ifdef DEBUG #define IFDEBUG IFTRUE #else #define IFDEBUG IFFALSE #endif #define debugf(parmlist) IFDEBUG(printf parmlist, )