Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!homxb!mtuxo!mtune!rutgers!sunybcs!boulder!hao!oddjob!mimsy!umd5!brl-adm!adm!ultra!wayne@ames.arpa From: wayne@ames.arpa Newsgroups: comp.lang.c Subject: How can I use #define to make something completely disappear? Message-ID: <10083@brl-adm.ARPA> Date: Fri, 30-Oct-87 18:00:02 EST Article-I.D.: brl-adm.10083 Posted: Fri Oct 30 18:00:02 1987 Date-Received: Sun, 1-Nov-87 09:31:45 EST Sender: news@brl-adm.ARPA Lines: 46 Time for my dumb question of the month ... I have the following sequence many times in a piece of code: #ifdef DEBUG printf("XYZ entry, p1=%x, p2=%x\n", p1, p2); #endif DEBUG Normal old obvious stuff, right? What I would like to do is replace all of these sequences with something like: DBPRINT("XYZ entry, p1=%x, p2=%x\n", p1, p2); and then have one instance of something like: #ifdef DEBUG #define DBPRINT printf #else #define DBPRINT But of course that doesn't make it; leaving the compiler with ("XYZ entry, p1=%x, p2=%x\n", p1, p2); won't help anything! For the above example I could of course say #ifdef DEBUG #define DBPRINT(a,b,c) printf(a,b,c) #else #define DBPRINT(a,b,c) but that only works when there are exactly three arguments, and obviously printf's can have more or less than that. Guess I could define DBPRINT1, DBPRINT2, DBPRINT3, etc., but that sounds less than aesthetic. Anybody got any suggestions? (Sure hope this is another one of those "Boy, that sure is easy; why are you bothering the net?" type things!) Wayne Hathaway ultra!wayne@Ames.ARPA Ultra Network Technologies 2140 Bering drive with a domain server: San Jose, CA 95131 wayne@Ultra.COM 408-922-0100