Kai-Uwe Bux said:
Marcus said:
Kai-Uwe Bux said:
The closest I found is [17.4.3.1.1/2]:
A translation unit that includes a header shall not contain any macros
that define names declared or defined in that header. Nor shall such a
translation unit define macros for names lexically identical to
keywords.
So, is that saying that if you don't include any headers, then
redefining keywords is fine?
The wording itself leaves open the question about translation units that do
not include headers. However, I have not found any provision in the
standard that would say you cannot redefine keywords in such translation
units. So, as far as I can tell, redefining keywords is well-defined in
that particular case.
Based on what you wrote, I am inclined to agree, though it is surprising
to me. Of course, I think it would be extremely difficult to write any
non-trivial program without using any headers at all.
I think that the rationale for the above allows for the situation in
which you manually implemented every particular feature you use, then it
would be possible to redefine the keywords to create some sort of
pseudo-language and be fully conforming. However, when including a
header, the original header implementer would probably assume standard
language semantics and thus redefining keywords would cause undefined
behavior because of the unforeseen changes in semantics.
Now, I may have missed something -- the standard is
huge.
Very true.