🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2604

Re: The Preprocessor and tokens

#2604
From: Norman Diamond
Date: Wed, 27 Mar 1991 03:35
31 lines
1813 bytes
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.

>Is there a good reason for this (other than the preprocessor is a little
>easier to write if you define [0-9][0-9a-zA-Z_]* as a token)?

No, there is no good reason for it.  The possible reason, which you suggest,
also falls pretty far short of being a good one.  There is no good reason.

>I was under the impression that the preprocessor and the compiler agreed
>on what constituted a token...

The standard specifically distinguishes preprocessor-tokens from tokens.
RTFS.

>Do K&R compilers do it any differently?

Usually.  The standard broke some working, valid, code this time.
--
Norman Diamond       diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Technical Details
Message-ID: <1991Mar27.033525.21697@tkou02.enet.dec.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!pa.dec.com!shlump.nac.dec.com!tkou02.enet.dec.com!jit345!diamond
References: <3137@wyse.wyse.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!pa.dec.com!shlump.nac.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: <1991Mar27.033525.21697@tkou02.enet.dec.com>
Date: 27 Mar 91 03:35:25 GMT
References: <3137@wyse.wyse.com>
Sender: news@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: 31