<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 1358: Add &lt;chrono&gt; and &lt;ratio&gt; to
freestanding implementations</title>
<meta property="og:title" content="Issue 1358: Add &lt;chrono&gt; and &lt;ratio&gt; to
freestanding implementations">
<meta property="og:description" content="C++ library issue. Status: NAD">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue1358.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#NAD">NAD</a> status.</em></p>
<h3 id="1358"><a href="lwg-closed.html#1358">1358</a>. Add <code>&lt;chrono&gt;</code> and <code>&lt;ratio&gt;</code> to
freestanding implementations</h3>
<p><b>Section:</b> 16.4.2.5 <a href="https://wg21.link/compliance">[compliance]</a> <b>Status:</b> <a href="lwg-active.html#NAD">NAD</a>
 <b>Submitter:</b> BSI <b>Opened:</b> 2010-08-25 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#compliance">issues</a> in [compliance].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#NAD">NAD</a> status.</p>
<p><b>Discussion:</b></p>
<p><b>Addresses GB-55</b></p>
<p>
The <code>&lt;thread&gt;</code> header uses <code>duration</code> types, found in the
<code>&lt;chrono&gt;</code> header, and which rely on the <code>ratio</code> types
declared in the <code>&lt;ratio></code> header.
</p>

<p><i>[
Extracts from lengthy Rapperswil discussion:
]</i></p>

<p>
There is a concern that this issue is a misunderstanding of the actual
requirements of a free-standing implementation to support the <code>&lt;thread></code>
header.  In general, a free-standanding implementation will provide an <em>empty</em>
header, specifically so that a user can test for the absence of the 
<code>_ _ STDCPP_THREADS _ _</code> macro.  This idiom as used as there is no portable 
way to test for the lack of a header.
</p>
<p>
At this point, it was suggested the NB comment is trying to solve the wrong problem, 
and that <code>_ _ STDCPP_THREADS _ _</code> should be a pre-defined macro in clause 16 
that can be tested before including <code>&lt;thread&gt;</code>.  That would remove the 
need to add additional headers to the free-standanding requirements.
</p>
<p>
It is worth noting that Japan requested <code>&lt;ratio&gt;</code> as a free-standing header 
in their CD1 comments.  No-one seemed keen to require clocks of a free-standing 
implementation though.
</p>

<p>Detlef volunteers to look at a way to redraft 17.6.1.3 p3.</p> 

<p><i>[
Original resolution proposed by NB comment:
]</i></p>


<blockquote>
<p>
Add the <code>&lt;chrono&gt;</code> and <code>&lt;ratio&gt;</code> headers to the
freestanding requirements.
</p>
<p>
It might be necessary to address scaled-down
expectations of clock support in a freestanding
environment, much like <code>&lt;thread&gt;</code>.
</p>
</blockquote>

<p><i>[2011-02-25: Alberto drafts wording]</i></p>


<p><i>[2011-03-06: Daniel observes:]</i></p>


<p>Accepting the proposal <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3256.html">n3256</a> 
would solve this issue.</p>

<p><i>[2011-03-24 Madrid meeting]</i></p>


<p>Freestanding no longer requires <code>&lt;thread&gt;</code> header</p>


<p><b>Rationale:</b></p><p>We are not adding new headers to freestanding at this point.</p>

<p id="res-1358"><b>Proposed resolution:</b></p>

<ol>
<li><p>Add a new entry in Table 14 &mdash; C++ library headers:</p>

<blockquote>
<table border="1">
<caption>Table 14 &mdash; C++ library headers</caption>
<tr>
<td style="text-align:center;">&hellip;</td>
</tr>
<tr>
<td><code>&lt;iterator&gt;</code></td>
</tr>
<tr>
<td><ins><code>&lt;library_support&gt;</code></ins></td>
</tr>
<tr>
<td><code>&lt;limits&gt;</code></td>
</tr>
<tr>
<td style="text-align:center;">&hellip;</td>
</tr>
</table>
</blockquote>  
</li>

<li><p>Remove the last row 32.4 <a href="https://wg21.link/thread.threads">[thread.threads]</a> <code>&lt;threads&gt;</code>
from Table 16 &mdash; C++ headers for freestanding implementations and insert
a new one instead (To the editor: For the actual target Clause please see the comment
in bullet 5 of this proposed resolution):</p>

<blockquote>
<table border="1">
<caption>Table 16 &mdash; C++ headers for freestanding implementations</caption>

<tr>
<th>Subclause</th>
<th>Header(s)</th>
</tr>

<tr>
<td colspan="2" style="text-align:center;">&hellip;</td>
</tr>

<tr>
<td><del>32.4 <a href="https://wg21.link/thread.threads">[thread.threads]</a> Threads</del></td>
<td><del><code>&lt;thread&gt;</code></del></td>
</tr>

<tr>
<td><ins>?? Library support</ins></td>
<td><ins><code>&lt;library_support&gt;</code></ins></td>
</tr>

</table>

</blockquote>
 </li>
 
 <li><p>Modify paragraph 16.4.2.5 <a href="https://wg21.link/compliance">[compliance]</a> p. 3:</p>
 <blockquote><p>
 3 The supplied version of the header <code>&lt;cstdlib&gt;</code> shall declare at least the functions 
 <code>abort</code>, <code>atexit</code>, <code>at_quick_exit</code>, <code>exit</code>, and <code>quick_exit</code> 
 (18.5). <del>The supplied version of the header <code>&lt;thread&gt;</code> shall meet the
same requirements as for a hosted implementation or including it shall have no effect</del>. The 
other headers listed in this table shall meet the same requirements as for a hosted 
implementation. <ins>A program can detect the presence of standard headers not listed in Table
16 using the facilities provided by the <code>&lt;library_support&gt;</code> header.</ins>
</p></blockquote>
</li>
 
<li><p>Remove the following line from the header <code>&lt;thread&gt;</code> synopsis in 
32.4 <a href="https://wg21.link/thread.threads">[thread.threads]</a> p. 1:</p>
<blockquote><pre>
namespace std {
  <del>#define __STDCPP_THREADS__ __cplusplus</del>

  class thread;
  [...]
}
</pre></blockquote>
</li>

<li><p>Add a new section in Clause 18 or 20 (or any other suitable place at
the editor's discretion):</p>

<blockquote>
<p><ins>?? Library support [library.support]</ins></p>
<blockquote><p>
<ins>The header <code>&lt;library_support&gt;</code> defines an implementation-defined set 
of macros to allow a program detect the presence of standard headers in freestanding
implementations. [<i>Note</i>: Hosted implementations shall provide all
standard headers, thus shall provide all macros. &mdash; <i>end note</i>]</ins>
</p></blockquote>
<blockquote><p>
<ins>For each standard header listed in Tables 14 (C++ library headers) and 15 (C++ headers for C library facilities)
that is provided by the implementation, <code>&lt;library_support&gt;</code> shall define a macro with name 
<code>_ _HAS_<i>XXX</i>_HEADER_ _</code> where <code><i>XXX</i></code> is replaced by the uppercase version of the 
name of the header. Each such macro shall expand to the value <code>_ _cplusplus</code>.
[<i>Example</i>:</ins></p>
<blockquote><pre>
<ins>#include &lt;library_support&gt;

#ifdef _ _HAS_THREADS_HEADER_ _
  #include &lt;threads&gt;
  // code that exploit the presence of threads
#else
  // fallback code that doesn't rely on threads
#endif</ins>
</pre></blockquote>
<p><ins>&mdash; <i>end example</i>]</ins></p>
</blockquote>
<blockquote><p>
<ins>No other standard header shall define macros with a name beginning with <code>_ _HAS_</code>
and ending with <code>_HEADER_ _</code>.</ins>
</p></blockquote>

</blockquote>
</li>
</ol>





</body>
</html>
