Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!btr!mips!wyse!cmills From: cmills@wyse.wyse.com (Chris Mills x2427 dept203) Newsgroups: comp.std.c Subject: Re: The Preprocessor and tokens Keywords: cpp Message-ID: <3140@wyse.wyse.com> Date: 28 Mar 91 19:19:39 GMT References: <3137@wyse.wyse.com> <1991Mar27.033525.21697@tkou02.enet.dec.com> Sender: news@wyse.wyse.com Reply-To: cmills@wyse.UUCP (Chris Mills x2427 dept203) Organization: Wyse Technology Lines: 45 In article <1991Mar27.033525.21697@tkou02.enet.dec.com> diamond@jit345.enet@tkou02.enet.dec.com (Norman Diamond) writes: >In article <3137@wyse.wyse.com> cmills@wyse.wyse.com () writes: > >>what does the Standard say about constuctions like these: >>#define _ + 42 >>int j = 6_; >>#define N 42 >>int k = 0x7e+N; > >The standard forbids those macros from being expanded. >However, since your program violates the ANSI syntax, the processor may do >whatever it wishes, as long as it produces at least one diagnostic. It >could, if it wishes, give a warning and then do what you asked for. What do you mean the preprocessor can do whatever it wants? If the standard forbids the expansions of the macros, then it can't do what I want, right? Actually, since I'm deliberately trying to be obfuscated, I'd like #include int N; #define N 3 void main(argc, argv) char **argv; { printf("%d\n", 0x7e+N); } to print 254 instead of 257 consistantly. What, exactly is being violated in this example that allows the preprocessor to be unpredictable? As my newfound understanding goes, the preproc. will see "0x73+N" as one token and will not expand "N", and the compiler will see it as three, right? >RTFS. Love to. Can't justify the cost of TFS for the occasional oddity like this. Did manage to borrow a copy of K&RII, but could not find any reference to the preprocessor being given license to think that numbers can contain W's... (I suppose allowing all alphabetics was slightly less confusing than allowing only [ulfeULFE]). By the way, does L"string" work the same way? Does the preproc. see this as one token, or two, and is Q"string" also a preproc token? Does anybody actually use these things? >-- >Norman Diamond diamond@tkov50.enet.dec.com >If this were the company's opinion, I wouldn't be allowed to post it. Chris Mills