C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: alternative tokens

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
llewelly
Guest





PostPosted: Wed Apr 21, 2004 3:54 pm    Post subject: Re: alternative tokens Reply with quote



[email]ank (AT) despammed (DOT) com[/email] (Alexander Krotov) writes:

[snip]
Quote:
Further, section 2.12 says:

preprocessing-op-or-punc: one of
..
new delete ...
and and_eq bitand bitor compl not not_eq or or_eq
xor xor_eq

..

Reserved words such as new and delete are different from alternative
tokens. Reserved words are unconditionally treated as keywords in
phase 7, but recieve no special treatment in phase 4, where
preprocessing directives are executed and macros are
expanded. (See section 2.1, as well as 2.12 .)

Quote:


Does this mean that "new", "delete", as well as alternative tokens
cannot be used as macro names (as they are preprocessing-op-or-puncs,
not identifiers) ?

Section 2.12 says:

2 In all respects of the language, each alternative token behaves the
same, respectively, as its primary token, except for its spelling5).
The set of alternative tokens is defined in Table 2.


Does this mean that alternative tokens can be used in preprocessor
conditional include conditions (#if) ?

Test:

#define not_eq X

ill-formed.

Quote:
#define new delete

well-formed.

Quote:

not_eq
new

#if 1 and 2

well-formed, condition is true.

Quote:
Foo.
#endif

#if 1 not_eq 2

well-formed, condition is true.

Quote:
Bar.
#endif


GCC 3.3 complains:
tp.c:1:9: "not_eq" cannot be used as a macro name as it is an operator in C++
and understands alternative tokens in #if conditions.

GCC is correct here. It is also correct to accept the two #if
preprocessoring conditionals.

Quote:
ICC 8.0 (as far as I know EDG based) complains
tp.c(9): error #14: extra text after expected end of preprocessing directive
#if 1 not_eq 2

ICC is wrong in this case.


---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.