<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2043: std{in,out,err} should be usable as field names</title>
<meta property="og:title" content="Issue 2043: std{in,out,err} should be usable as field names">
<meta property="og:description" content="C++ library issue. Status: NAD">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2043.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="2043"><a href="lwg-closed.html#2043">2043</a>. <code>std{in,out,err}</code> should be usable as field names</h3>
<p><b>Section:</b> 31.13 <a href="https://wg21.link/c.files">[c.files]</a> <b>Status:</b> <a href="lwg-active.html#NAD">NAD</a>
 <b>Submitter:</b> Jeffrey Yasskin <b>Opened:</b> 2011-03-23 <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#c.files">issues</a> in [c.files].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#NAD">NAD</a> status.</p>
<p><b>Discussion:</b></p>
<p>
People often define structs and classes with fields named <code>stdin</code>,
<code>stdout</code>, or <code>stderr</code>. According to 31.13 <a href="https://wg21.link/c.files">[c.files]</a>, 
though, these are macros.
<p/>
glibc defines them to themselves, allowing their non-portable use as
field names, while the Mac OS X libc defines them to either <code>__stdoutp</code>
or <code>(&amp;__sF[1])</code>, etc depending on <code>__DARWIN_UNIX03</code>. It's possible to
allow their use while, as far as I can see, only requiring minor
changes to various libc's, so C++1x should allow it.
</p>

<p><i>[
2011 Bloomington
]</i></p>


<p>
Closed as NAD.  This is an extension request that has been an issue for over 20 years.
Supporting the extension would place a burden on the underlying C library that we may
not be in a position to influence.
</p>



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

<p>This wording is relative to the FDIS.</p>

<ol>
<li><p>In 31.13 <a href="https://wg21.link/c.files">[c.files]</a> add "stderr", "stdin", and "stdout" to a new Values section in Table
134 &mdash; Header <code>&lt;cstdio&gt;</code> synopsis:</p>

<blockquote>
<table border="1">
<caption>134 &mdash; Header <code>&lt;cstdio&gt;</code> synopsis</caption>

<tr>
<th colspan="6" style="text-align:center;">Type Name(s)</th>
</tr>

<tr>
<th colspan="6" style="text-align:left;">Macros:</th>
</tr>

<tr>
<td><code>BUFSIZ</code></td>
<td><code>FOPEN_MAX</code></td>
<td><code>SEEK_CUR</code></td>
<td><code>TMP_MAX</code></td>
<td><code>_IONBF</code></td>
<td><code>stdout</code></td>
</tr>

<tr>
<td><code>EOF</code></td>
<td><code>L_tmpnam</code></td>
<td><code>SEEK_END</code></td>
<td><code>_IOFBF</code></td>
<td><code>stderr</code></td>
<td>&nbsp;</td>
</tr>

<tr>
<td><code>FILENAME_MAX</code></td>
<td><code>NULL &lt;cstdio&gt;</code></td>
<td><code>SEEK_SET</code></td>
<td><code>_IOLBF</code></td>
<td><code>stdin</code></td>
<td>&nbsp;</td>
</tr>

<tr>
<th style="text-align:left;">Types:</th>
<td><code>FILE</code></td>
<td><code>fpos_t</code></td>
<td><code>size_t &lt;cstdio&gt;</code></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

<tr>
<th colspan="6" style="text-align:left;">Functions:</th>
</tr>

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

<tr>
<th colspan="6" style="text-align:left;"><ins>Values:</ins></th>
</tr>

<tr>
<td><ins><code>stderr</code></ins></td>
<td><ins><code>stdin</code></ins></td>
<td><ins><code>stdout</code></ins></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

</table>
</blockquote>

</li>

<li><p>Add a new paragraph after paragraph 2 as indicated:</p>

<blockquote><p>
2 Calls to the function <code>tmpnam</code> with an argument of <code>NULL</code> may 
introduce a data race (17.6.5.9) with other calls to <code>tmpnam</code> with an 
argument of <code>NULL</code>.<br/>
See also: ISO C 7.9, Amendment 1 4.6.2.
<p/>
<ins>? The macros <code>stderr</code>, <code>stdin</code>, and <code>stdout</code> shall 
expand to <code>stderr</code>, <code>stdin</code>, and <code>stdout</code>, respectively. 
[<i>Note:</i> This allows uses of <code>#ifdef</code> to detect their presence, 
while allowing code in other scopes to use them as identifiers. &mdash; <i>end note</i>]</ins>
</p></blockquote>
</li>

<li><p>In C.8 <a href="https://wg21.link/diff.library">[diff.library]</a> add "stderr", "stdin", and "stdout" to 
Table 150 &mdash; Standard values:</p>

<blockquote>
<table border="1">
<caption>Table 150 &mdash; Standard values</caption>

<tr>
<td><code>CHAR_BIT</code></td>
<td><code>FLT_DIG</code></td>
<td><code>INT_MIN</code></td>
<td><code>MB_LEN_MAX</code></td>
</tr>

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

<tr>
<td>&hellip;</td>
<td>&hellip;</td>
<td>&hellip;</td>
<td><code>SHRT_MIN</code></td>
</tr>

<tr>
<td>&hellip;</td>
<td>&hellip;</td>
<td>&hellip;</td>
<td><ins><code>stderr</code></ins></td>
</tr>

<tr>
<td>&hellip;</td>
<td>&hellip;</td>
<td>&hellip;</td>
<td><ins><code>stdin</code></ins></td>
</tr>

<tr>
<td>&hellip;</td>
<td>&hellip;</td>
<td>&hellip;</td>
<td><ins><code>stdout</code></ins></td>
</tr>

<tr>
<td>&hellip;</td>
<td>&hellip;</td>
<td>&hellip;</td>
<td><code>UCHAR_MAX</code></td>
</tr>

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

</table>
</blockquote>

</li>

</ol>






</body>
</html>
