Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!orchid!rbutterworth From: rbutterworth@orchid.UUCP Newsgroups: comp.lang.c Subject: Re: #if inside #define -- easy to do, but is it a good idea? Message-ID: <10898@orchid.waterloo.edu> Date: Tue, 29-Sep-87 14:24:40 EDT Article-I.D.: orchid.10898 Posted: Tue Sep 29 14:24:40 1987 Date-Received: Thu, 1-Oct-87 01:11:39 EDT References: <157@decvax.UUCP> <29339@sun.uucp> Organization: U of Waterloo, Ontario Lines: 33 In article <29339@sun.uucp>, david@sun.uucp (David DiGiacomo) writes: > In article <157@decvax.UUCP> minow@decvax.UUCP (Martin Minow) writes: > >From time immemorial, C has forbidden # control lines inside a > >macro definition. > It would be a nice feature to have, but it's not really necessary for your > example OK, here's a real example where it would be useful (in fact I can't see any nice way of doing this without the ability): #if !defined(compiler_A) #if !defined(compiler_B) #if !defined(compiler_C) ^%$%^#^%$&^% syntax error since we don't know this compiler. #else /* compiler_C */ # define ARGSUSED /*ARGSUSED*/ #endif /* compiler_C */ #else /* compiler_B */ # define ARGSUSED #argsused #endif /* compiler_B */ #else /* compiler_A */ # define ARGSUSED #pragma argsused #endif /* compiler_A */ goes into a header file, and a program can simply use the manifest ARGSUSED in the appropriate places. Without this ability, the source gets rather ugly if it is to run on all three compilers.