Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site sdchema.UUCP Path: utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!sdchema!jwp From: jwp@sdchema.UUCP Newsgroups: net.lang.c Subject: Re: Preprocessor Trickery Message-ID: <198@sdchema.UUCP> Date: Thu, 12-Jul-84 22:55:49 EDT Article-I.D.: sdchema.198 Posted: Thu Jul 12 22:55:49 1984 Date-Received: Sat, 14-Jul-84 13:46:29 EDT References: <199@haddock.UUCP>, <1014@elsie.UUCP> Organization: Chemistry Dept, UC San Diego Lines: 25 ...!elsie!ado: >Try typing this to see what happens: > cc -E - > #define Ident(xxx) xxx > #define concat(a,b) Ident(a)b > __LINE__ > concat(__LINE__,__LINE__) "concat(__LINE__,__LINE__)" gives "__LINE____LINE__" "concat(__LINE__, __LINE__)" gives, e.g., "3 3" For that matter: "concat(this,that)" results in "thisthat" "concat(this, that)" results in "this that" Defining "concat(a, b)" instead of "concat(a,b)" doesn't, however, seem to make a difference. It *is* interesting behavior. And also reinforces my general feelings that: (a) relying on the preprocessor to do too much for you is foolish, and (b) being very clever is a really fun way to screw up those that follow you (or yourself when you have to go back to the miserable thing two years later and have forgotten how terribly clever you were), especially when you follow the customary C commenting conventions. John Pierce, Chemistry, UC San Diego sdcsvax!sdchema!jwp