ISO/IEC JTC1 SC22 WG21 N3280 = 11-0050 - 2011-03-24
Lawrence Crowl, crowl@google.com, Lawrence@Crowl.org
Alberto Ganesh Barbati, ganesh@barbati.net
This paper is a revision of N3256 = 11-0026 - 2011-02-27.
Introduction
Wording Changes
16.8 Predefined macro names [cpp.predefined]
17.6.1.3 Freestanding implementations [compliance]
30.3 Threads [thread.threads]
CD comment DE 18 requested a macro to indicate the presence of threads. The response was a rather convoluted "ineffective <thread> header". This response failed to solve the real problem, and caused FCD comment GB 55. In addition, the change exacerbated incompatibilities between C and C++.
This paper provides the minimal fixes in this area for C++0x. They specifically satisfy
A macro that indicates the presence of threads in the core language is generally more applicable than one that only indicates the availability of library components. This approach is consistent with the wording in 1.10 [intro.multithread].
The <mutex> header is more likely to be implemented in freestanding implementations than is <thread> and yet their freestanding requirements are opposite. Furthermore, there are many single-threaded embedded systems. So, <thread> should not be required of freestanding implementations. Consequently, <ratio> and <chrono> would not need to be freestanding and GB 55 would become moot.
The set of freestanding headers required by C++ should include at least those required by C. Implementors will anyway because few would support only C++, so failing to support those headers simply invites an inconsistency between the standard and practice.
Add the following to the end of paragraph 2.
__STDCPP_THREADS__
- Defined, and has the integer value constant 1, if and only if a program can have more than one thread of execution (1.10 intro.multithread).
Edit table 16 as follows.
Table 16 — C++ headers for freestanding implementations Subclause Header(s) 17.6.1.2, C.2.2.3 Named operators <ciso646>
18.2 Types <cstddef>
18.3 Implementation properties <cfloat> <limits> <climits>
18.4 Integer types <cstdint>
... ... ... 18.10 Other runtime support <cstdalign> <cstdarg> <cstdbool>
... ... ... 29 Atomics <atomic>
30.3Threads<thread>
Edit paragraph 3 as follows.
The supplied version of the header
<cstdlib>
shall declare at least the functionsabort
,atexit
,at_quick_exit
,exit
, andquick_exit
(18.5).The supplied version of the headerThe other headers listed in this table shall meet the same requirements as for a hosted implementation.<thread>
shall meet the same requirements as for a hosted implementation or including it shall have no effect.
Edit the synopsis as follows.
namespace std {
#define __STDCPP_THREADS__ __cplusplus....