Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!mcnc!rti!xyzzy!kulik From: kulik@xyzzy.UUCP (Al Kulik) Newsgroups: comp.lang.c Subject: Re: macros with parameters in MSC 5.0 Message-ID: <666@xyzzy.UUCP> Date: 4 Mar 88 20:31:08 GMT References: <11879@brl-adm.ARPA> <2631@haddock.ISC.COM> <898@PT.CS.CMU.EDU> <290@alice.marlow.reuters.co.uk> Reply-To: kulik@xyzzy.UUCP () Organization: Data General Corporation, Research Triangle, NC Lines: 37 In article <290@alice.marlow.reuters.co.uk> fox@alice.marlow.reuters.co.uk (Paul Fox) writes: >ANSI gets around this [macro argument substitution in string literals] via the >'#' and '##' operators -- available within the preprocessor phase only. As I >read it > ># define CTRL(x) #x & 037 > CTRL(A); > >gives: "A" & 037 > ># define CTRL(x) '##x##' & 037 > CTRL(A); ^^^^^^^ > >gives: 'A' & 037 > I don't know about this. It seems to me that this would result in '##x##' & 037. '##x##' is a character constant which is a preprocessor token; the preprocessor will not recognize the ##s within the token, they're just part of the constant. In the first case above, "A" & 037 results in the address of the literal "A" being ANDed bitwise with the constant 037, which may not be what you want. To obtain something like the second case: #define CTRL(x) #x[0] & 037. -- Al Kulik, Data General. Uucp: ...!mcnc!rti!xyzzy!kulik Arpa/Csnet: kulik@dg-rtp.DG.COM