Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofCD1 status.

294. User defined macros and standard headers

Section: 16.4.5.3.3[macro.names]Status:CD1Submitter: James KanzeOpened: 2001-01-11Last modified: 2016-01-28

Priority:Not Prioritized

View all otherissues in [macro.names].

View all issues withCD1 status.

Discussion:

Paragraph 2 of 16.4.5.3.3[macro.names] reads: "Atranslation unit that includes a header shall not contain any macrosthat define names declared in that header." As I read this, itwould mean that the following program is legal:

  #define npos 3.14  #include <sstream>

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

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

Proposed resolution:

For 16.4.5.3.3[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.

[Lillehammer: Beman provided new wording]


[8]ページ先頭

©2009-2026 Movatter.jp