Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!linac!att!pacbell.com!decwrl!pa.dec.com!jrdzzz.jrd.dec.com!tkou02.enet.dec.com!jit345!diamond From: diamond@jit345.swstokyo.dec.com (Norman Diamond) Newsgroups: comp.std.c Subject: Re: The Preprocessor and tokens Keywords: cpp Message-ID: <1991Mar29.073102.1136@tkou02.enet.dec.com> Date: 29 Mar 91 07:31:02 GMT References: <3137@wyse.wyse.com> <1991Mar27.033525.21697@tkou02.enet.dec.com> <3140@wyse.wyse.com> Sender: usenet@tkou02.enet.dec.com (USENET News System) Reply-To: diamond@jit345.enet@tkou02.enet.dec.com (Norman Diamond) Organization: Digital Equipment Corporation Japan , Tokyo Lines: 66 In article <3140@wyse.wyse.com> cmills@wyse.UUCP (Chris Mills x2427 dept203) writes: >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? The PREPROCESSOR is not allowed to do this expansion. AFTER preprocessing, the PROCESSOR must give at least one diagnostic. The PROCESSOR is then allowed to proceed as it likes, including, uh, repreprocessing. Of course, the processor does not really have to break out a separate preprocessor step; it only has to behave as though the phases of translation occured in the standard order. >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. Not from ANSI 1989 C. >As my newfound understanding goes, the preproc. will see "0x73+N" as one >token and will not expand "N", Yes. >and the compiler will see it as three, right? No. The compiler will see it as one, issue at least one diagnostic, and then do whatever it wishes (including possibly converting it to three). >>RTFS. >Love to. Can't justify the cost of TFS for the occasional oddity like this. If you can't justify $50.00, then you can't afford to use net bandwidth on it either. >By the way, does L"string" work the same way? Does the preproc. see this as >one token, or two, One. >and is Q"string" also a preproc token? No. For consistency it should have been (sarcasm here). >Does anybody actually use these things? People have actually used strings with multibyte characters in them for over 10 years. The L"..." syntax was (to the best of my knowledge) an ANSI invention and not previously used. At least this one did not break working programs. -- Norman Diamond diamond@tkov50.enet.dec.com If this were the company's opinion, I wouldn't be allowed to post it.