Title
User defined macros and standard headers
Status
cd1
Section
[macro.names]
Submitter
James Kanze

Created on 2001-01-11.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

[ Lillehammer: Beman provided new wording ]

Date: 2010-10-21.18:28:33

Proposed resolution:

For [macro.names], replace the current wording, which reads:

Each name defined as a macro in a header is reserved to the implementation for any use if the translation unit includes the header.168)

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.

168) It is not permissible to remove a library macro definition by using the #undef directive.

with the wording:

A translation unit that includes a standard library header shall not #define or #undef names declared in any standard library header.

A translation unit shall not #define or #undef names lexically identical to keywords.

Date: 2001-01-11.00:00:00

Paragraph 2 of [macro.names] reads: "A translation unit that includes a header shall not contain any macros that define names declared in that header." As I read this, it would mean that the following program is legal:

  #define npos 3.14
  #include <sstream>

since npos is not defined in <sstream>. It is, however, defined in <string>, and it is hard to imagine an implementation in which <sstream> didn't include <string>.

I think that this phrase was probably formulated before it was decided that a standard header may freely include other standard headers. The phrase would be perfectly appropriate for C, for example. In light of [res.on.headers] paragraph 1, however, it isn't stringent enough.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2139
2010-10-21 18:28:33adminsetmessages: + msg2138
2001-01-11 00:00:00admincreate