Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!cica!iuvax!purdue!decwrl!nsc!taux01!tasu23!yval From: yval@tasu23.UUCP (Yuval Yarom) Newsgroups: comp.lang.c Subject: Re: Nested Macros Message-ID: <2913@taux01.UUCP> Date: 21 Nov 89 07:49:31 GMT References: Sender: netnews@taux01.UUCP Reply-To: yval%taux01@nsc.nsc.com (Yuval Yarom) Organization: National Semiconductor (IC) Ltd, Israel Lines: 30 In article jb3o+@andrew.cmu.edu (Jon Allen Boone) writes: >A friend is attempting to write a macro along the following lines: > >#define DEBUG 1 > >#define DB(X) #ifdef (DEBUG) printf(X) > >however, this results in an error when he attempts to compile it. > >does anyone know how he would go about writing a macro that would >allow him to simply type DB(x) in his code and not have to type #ifdef >(DEBUG) printf(X) everywhere instead? Any help would be greatly >appreciated. Please carbon copy your reply to pg0p@andrew.cmu.edu, as >well as to jb3o@andrew.cmu.edu and the board. > >thank you... He should use: #define DEBUG 1 #ifdef DEBUG #define DB(X) printf(X) #else #define DB(X) /* */ #endif -- Yuval Yarom yval%taux01@nsc.nsc.com