Article View: comp.std.c
Article #4147sizeof != identifier
From: Daniel Villeneuve
Date: Sun, 01 Oct 1995 16:27
Date: Sun, 01 Oct 1995 16:27
23 lines
1415 bytes
1415 bytes
As I'm reading the lexical rules of the standard, it appears to me that, as early as translation phase 3, the file is decomposed into a stream of preprocessing tokens and the `sizeof' string is then converted into the `operator' token as listed in section 3.1.5. If so, this prohibits the use of `sizeof' as an identifier anywhere in a program, including in the syntax rule for defining macros, which reads like this: # define identifier replacement-list new-line # define identifier lparen replacement-list ) new-line because preprocessor directives execution and macro substitution occurs at translation phase 4. Trying this with gcc and c89 (HP), both accepted `sizeof' as a valid identifier. The code violating a syntax rule, shouldn't the compilers issue a diagnostic for that? ----------------------------------------------------------------------- Daniel Villeneuve Tel: +1 514 340 6046 Graduate student in Operations Research Fax: +1 514 340 5665 GERAD/Mathematiques Appliquees Email: danielv@crt.umontreal.ca Ecole Polytechnique de Montreal
Technical Details
Message-ID:
<DANIELV.95Oct1122701@crt0.crt>Path:
arc1-ca.pugleaf.net!CC.UMontreal.CA!newsShow Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!CC.UMontreal.CA!news From: danielv@crt0.crt (Daniel Villeneuve) Subject: sizeof != identifier Message-ID: <DANIELV.95Oct1122701@crt0.crt> Sender: news@cc.umontreal.ca (Administration de Cnews) Organization: Universite de Montreal Date: Sun, 1 Oct 1995 16:27:00 GMT