Path: utzoo!attcan!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.lang.c Subject: Re: ANSI Preprocessor Was: how widespread is this cpp bug? Message-ID: <678@auspex.UUCP> Date: 11 Dec 88 01:46:06 GMT References: <9026@smoke.BRL.MIL> <406@cvbnet2.UUCP> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 43 >#define MAC_RO1(string1, string2) "strings1string2" > >If you feed MAC_RO1 like so > > MAC_RO1(dir, file) > >you get > > "dirfile" > >Can you accomplish anything similar with ANSI C? #define MAC_RO1(string1, string2) #string1 #string2 should do it, since: 1) "#" preceding an occurrence of a formal argument in the body of a macro turns it into a string 2) adjacent string literals are concatenated hence MAC_RO1(dir, file) gets expanded to "dir" "file" which gets turned into "dirfile" >I guess what I'm asking for is a preprocessor tutorial in respect to >ANSI-C. A topic that's probably too big for a posting on comp.lang.c, although somebody may post some further tutorial information. You might check out Kernighan & Ritchie, second edition, which is, to quote the blurb in the upper right hand corner of the cover, "Based on Draft-Proposed ANSI C" (BTW, "Draft-Proposed ANSI C" is often abbreviated as dpANS, especially in this newsgroup).