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.

310. Is errno a macro?

Section: 16.4.2.3[headers], 19.4[errno]Status:CD1Submitter: Steve ClamageOpened: 2001-03-21Last modified: 2016-01-28

Priority:Not Prioritized

View all otherissues in [headers].

View all issues withCD1 status.

Discussion:

Exactly how should errno be declared in a conforming C++ header?

The C standard says in 7.1.4 that it is unspecified whether errno is a macro or an identifier with external linkage. In some implementations it can be either, depending on compile-time options. (E.g., on Solaris in multi-threading mode, errno is a macro that expands to a function call, but is an extern int otherwise. "Unspecified" allows such variability.)

The C++ standard:

I find no other references to errno.

We should either explicitly say that errno must be a macro, even though it need not be a macro in C, or else explicitly leave it unspecified. We also need to say something about namespace std. A user who includes <cerrno> needs to know whether to writeerrno, or::errno, orstd::errno, or else <cerrno> is useless.

Two acceptable fixes:

[ This issue was first raised in 1999, but it slipped through the cracks. ]

Proposed resolution:

Change the Note in section 17.4.1.2p5 from

Note: the names defined as macros in C include the following: assert, errno, offsetof, setjmp, va_arg, va_end, and va_start.

to

Note: the names defined as macros in C include the following: assert, offsetof, setjmp, va_arg, va_end, and va_start.

In section 19.3, change paragraph 2 from

The contents are the same as the Standard C library header <errno.h>.

to

The contents are the same as the Standard C library header <errno.h>, except that errno shall be defined as a macro.

Rationale:

C++ must not leave it up to the implementation to decide whether ornot a name is a macro; it must explicitly specify exactly which namesare required to be macros. The only one that really works is for itto be a macro.

[Curaçao: additional rationale added.]


[8]ページ先頭

©2009-2026 Movatter.jp