Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!ll-xn!ames!oliveb!sun!david From: david@sun.uucp (David DiGiacomo) Newsgroups: comp.lang.c Subject: Re: #if inside #define -- easy to do, but is it a good idea? Message-ID: <29339@sun.uucp> Date: Mon, 28-Sep-87 18:30:43 EDT Article-I.D.: sun.29339 Posted: Mon Sep 28 18:30:43 1987 Date-Received: Wed, 30-Sep-87 01:11:14 EDT References: <157@decvax.UUCP> Organization: Sun Microsystems, Inc. - Mtn View, CA Lines: 27 In article <157@decvax.UUCP> minow@decvax.UUCP (Martin Minow) writes: >From time immemorial, C has forbidden # control lines inside a >macro definition. When a collegue begged for this capability, >I discovered it was trivial to add it to Decus CPP (which was posted >to Usenet mod.sources about 2-3 years ago). It might be used >as follows: > #define set_bit(bit) \ > #if debug \ > printf("setting %04x\n", bit), \ > #endif \ > (device_register = (bit)) It would be a nice feature to have, but it's not really necessary for your example: #if debug #define IFDEBUG(x) x #else #define IFDEBUG(x) #endif #define set_bit(bit) \ IFDEBUG(printf("setting %04x\n", bit);) \ (device_register = (bit)) -- David DiGiacomo, Sun Microsystems, Mt. View, CA sun!david david@sun.com