using macros ...

J

Jun Woong

Dan Pop said:
Well, the implementor can "shadow" each keyword by an alias with the same
name, but prefixed by a double underscore and use the aliases in the
standard headers.

It's doubtful how many implementations provide such built-in "shadows"
and how many implementers even know that they should not use keywords
in implementing macros for the standard library. In this sense, it's
surely tricky, and I'd be happy if the committee decides to prohibit
masking keywords.
The things get hairy only for people trying to provide "portable"
implementations of the standard library, because they can't afford this
luxury. The standard types can be easily typedef'ed to reserved
identifiers, but there is no similar workaround for the other keywords.

One important example is sizeof, as I mentioned, which is an operator
and very useful when making macros for some standard functions imitate
the functions' behavior more well.
 
D

Dan Pop

In said:
Dan Pop said:
[...]

Alternately, either the programmer isn't allowed to define preprocessor
macros with the same names as type names (perhaps all keywords?), or the
implementation really should do something like "typedef void *__voidptr"
and use a cast to __voidptr in NULL (and do something similar for other
type names it uses in macros) instead of using type names that the
programmer is allowed to mangle.


The latter, which makes it very tricky to implement the standard
library corretly.

Well, the implementor can "shadow" each keyword by an alias with the same
name, but prefixed by a double underscore and use the aliases in the
standard headers.

It's doubtful how many implementations provide such built-in "shadows"
and how many implementers even know that they should not use keywords
in implementing macros for the standard library. In this sense, it's
surely tricky, and I'd be happy if the committee decides to prohibit
masking keywords.

OTOH, the built-in "shadows" provide a very simple solution to the
problem, once the implementor is aware of the problem.

I would be happy too to see the keywords as fully reserved identifiers,
but it is obvious that the committee members *deliberately* decided
otherwise and you know as well as myself how reluctant they are to
reverse their decisions...

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,219
Latest member
Geraldine7

Latest Threads

Top