Dennis said:
Ok, I kept talking about the immplementation providing _MAX_POWER as a
variable.
It could define it as a keyword if it choose, which would be even more
problematic.
If it's only for its own use, then would it be in a public header?
Because it is used in the macro implementation of a standard function or
standard macro. Real implementations do these kind of things all the
time and they are explicitly allowed to by the standard.
For example, the stddef.h on this machine includes the line...
#define NULL __DARWIN_NULL
So obviously there is a symbol or keyword __DARWIN_NULL defined
somewhere (which I've not bothered to track down, and it could even be
built in to the compiler). However, I'm not aware of any documentation
saying that this identify is intended is intended for you to use (and I
would be very surprised if it was).
Sure it is. The question just asked what was a valid idetifier.
Said nothing about context, so all should be considered.
Um, it is *you* how just introduced a context, i.e. the context in which
any identifier has already been described.
In any case I say again that if you are considering all contexts you
have to consider that in some contexts it is NOT valid, such as an
implementation which has a keyword of __MAX_POWER (which it is allowed to).
That wasn't the question though.
The second paragraph is reasonable context for the question (i.e.
suggesting what it is reasonable to tell a beginner). The first
paragraph is pointing out that if you are considering all contexts
(because none was specified) you need to include those implementations
which choose to make it invalid to use it as an identifier (which they
are allowed to) by causing and translation unit containing that
identifier to fail to translate.
That's not what the question was though.
The question does not exclude implementations where it is "illegal" to
use it as an identifier, so saying it is valid is claiming you can use
it on an implementation where it is guaranteed to cause compilation to fail.
By "doing something" means "defining a symbol with that name", means
that the identifier is valid, else the implementation could not use it
either.
I considered the original question to be implicitly talking about what
is valid in user code, but if you want to include identifiers defined by
the implementation, then the implementation could define it as a
keyword, in which case it is not an identifier defined by the
implementation nor is it something that can be used as an identifier in
user code. An example of such a thing being done is the __try keyword
provided (quite legally) by some implementations.
I answered that below. It reads more into the question than was asked.
I disagree.
be sure that's what you're asking though.
If you simply ask what is a valid identifier, then you leave it open for
identifiers in all contexts - user-defined or implementation defined.
Well, the implementation could define a keyword __MAX_POWER, in which
case it is not an identifier nor can an identifier of that name be
declared or defined. It could even define it as a keyword with similar
semantics to the #error directive, i.e. causing compilation to abort.
However, it is normally considered implicit in questions like "is X
allowed (or valid) in C?" that the question is referring to user code
rather than tricks the implementation might be using internally whilst
not allowing user code to use them. This is especially the case with
questions targetted at beginners.