This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: C++ alternative tokens in the preprocessor


On Tue, Jul 18, 2000 at 08:50:17PM +0200, Martin v. Loewis wrote:
> > > #define a 1
> > > #define b 2
> > > #if a and b
> > > int i=0;
> > > #endif
> > 
> > Interesting.  Where can I find that in the C++ standard?
> 
> 2.5., Alternative tokens.

Thanks.  I do have a copy of C++98, so the section is all I need.

> > This patch has a number of problems.  The biggest one is that you've
> > penalized the normal case of parse_name, since these identifiers are
> > not often used.  parse_name is already a performance bottleneck for
> > cpplib.
> 
> Please note that the penalty is very small.

Sorry, *any* penalty in this function is too much.  parse_name already
takes 10% of user CPU time, second only to lex_line and cpp_lookup
(15% each).

Keep in mind that the normal case will be to walk through the entire
list and find no match.  Also keep in mind that most identifiers are
short.

> > Also, remember to prevent people from re#defining these identifiers.
> 
> That already works, for
> 
> #define and 45
> 
> I get
> 
> a.cc:1:9: macro names must be identifiers

This is not a good error message.  It expects the user to know gritty
details of the official grammar.  I would much rather see something
like

a.cc:1:9: "and" is not a legal macro name in C++

zw

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]