summaryrefslogtreecommitdiff
path: root/devdocs/c/error%2Ferrno_macros.html
blob: 5ecee98fed186412bd1e8569fa7910292dfed224 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
    <h1 id="firstHeading" class="firstHeading">Error numbers</h1>            <p>Each of the macros defined in <code>&lt;errno.h&gt;</code> expands to an integer constant expression with type <code>int</code> and with a unique positive value. The following constants are defined by ISO C. The implementation may define more, as long as they begin with <code>'E'</code> followed by digits or uppercase letters.</p>
<table class="t-dsc-begin"> <tr class="t-dsc-header"> <th colspan="2"> Defined in header <code>&lt;errno.h&gt;</code>  </th>
</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>EDOM</span></span></div> </td> <td> Mathematics argument out of domain of function <br> <span class="t-mark">(macro constant)</span> </td>
</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>EILSEQ</span></span></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div> </td> <td> Illegal byte sequence <br> <span class="t-mark">(macro constant)</span> </td>
</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>ERANGE</span></span></div> </td> <td> Result too large <br> <span class="t-mark">(macro constant)</span> </td>
</tr> </table>  <h3 id="Notes"> Notes</h3> <p>Many additional errno constants are <a rel="nofollow" class="external text" href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html">defined by POSIX</a> and by the <a href="https://en.cppreference.com/w/cpp/error/errno_macros" title="cpp/error/errno macros">C++ standard library</a>, and individual implementations may define even more, e.g. <code>errno(3)</code> on Linux or <code>intro(2)</code> on BSD and OS X.</p>
<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;stdio.h&gt;
#include &lt;math.h&gt;
#include &lt;errno.h&gt;
#include &lt;string.h&gt;
 
int main(void)
{
    errno = 0;
    printf("log(-1.0) = %f\n", log(-1.0));
    printf("%s\n\n",strerror(errno));
 
    errno = 0;
    printf("log(0.0)  = %f\n", log(0.0));
    printf("%s\n",strerror(errno));
}</pre></div> <p>Possible output:</p>
<div class="text source-text"><pre data-language="c">log(-1.0) = nan
Numerical argument out of domain
 
log(0.0)  = -inf
Numerical result out of range</pre></div> </div> <h3 id="References"> References</h3>  <ul>
<li> C11 standard (ISO/IEC 9899:2011): </li>
<ul><li> 7.5/2 Errors &lt;errno.h&gt; (p: 205) </li></ul>
<li> C99 standard (ISO/IEC 9899:1999): </li>
<ul><li> 7.5/2 Errors &lt;errno.h&gt; (p: 186) </li></ul>
<li> C89/C90 standard (ISO/IEC 9899:1990): </li>
<ul><li> 4.1.3 Errors &lt;errno.h&gt; </li></ul>
</ul>         <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="errno" title="c/error/errno"> <span class="t-lines"><span>errno</span></span></a></div> </td> <td> macro which expands to POSIX-compatible thread-local error number variable<br><span class="t-mark">(macro variable)</span>  </td>
</tr> <tr class="t-dsc"> <td> <div><a href="../io/perror" title="c/io/perror"> <span class="t-lines"><span>perror</span></span></a></div> </td> <td> displays a character string corresponding of the current error to <code><a href="../io/std_streams" title="c/io/std streams">stderr</a></code> <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td> <div><a href="../string/byte/strerror" title="c/string/byte/strerror"> <span class="t-lines"><span>strerror</span><span>strerror_s</span><span>strerrorlen_s</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> returns a text version of a given error code <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/error/errno_macros" title="cpp/error/errno macros">C++ documentation</a></span> for <span class=""><span>Error numbers</span></span> </td>
</tr> </table>            <div class="_attribution">
  <p class="_attribution-p">
    &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
    <a href="https://en.cppreference.com/w/c/error/errno_macros" class="_attribution-link">https://en.cppreference.com/w/c/error/errno_macros</a>
  </p>
</div>