summaryrefslogtreecommitdiff
path: root/devdocs/c/error%2Fabort_handler_s.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/c/error%2Fabort_handler_s.html')
-rw-r--r--devdocs/c/error%2Fabort_handler_s.html51
1 files changed, 51 insertions, 0 deletions
diff --git a/devdocs/c/error%2Fabort_handler_s.html b/devdocs/c/error%2Fabort_handler_s.html
new file mode 100644
index 00000000..dbf90720
--- /dev/null
+++ b/devdocs/c/error%2Fabort_handler_s.html
@@ -0,0 +1,51 @@
+ <h1 id="firstHeading" class="firstHeading">abort_handler_s</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;stdlib.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c11"> <td> <pre data-language="c">void abort_handler_s( const char * restrict msg,
+ void * restrict ptr,
+ errno_t error
+ );</pre>
+</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> </table> <p>Writes an implementation-defined message to <code><a href="../io/std_streams" title="c/io/std streams">stderr</a></code> which must include the string pointed to by <code>msg</code> and calls <code><a href="../program/abort" title="c/program/abort">abort()</a></code>.</p>
+<p>A pointer to this function can be passed to <a href="set_constraint_handler_s" title="c/error/set constraint handler s">set_constraint_handler_s</a> to establish a runtime constraints violation handler. As with all bounds-checked functions, <code>abort_handler_s</code> is only guaranteed to be available if <code>__STDC_LIB_EXT1__</code> is defined by the implementation and if the user defines <code>__STDC_WANT_LIB_EXT1__</code> to the integer constant <code>1</code> before including <code>&lt;stdlib.h&gt;</code>.</p>
+<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> msg </td> <td> - </td> <td> pointer to the message written to the standard error stream </td>
+</tr> <tr class="t-par"> <td> ptr </td> <td> - </td> <td> pointer to an implementation-defined object or a null pointer. Examples of implementation-defined objects are objects that give the name of the function that detected the violation and the line number when the violation was detected </td>
+</tr> <tr class="t-par"> <td> error </td> <td> - </td> <td> a positive value of type errno_t </td>
+</tr>
+</table> <h3 id="Return_value"> Return value</h3> <p>none; this function does not return to its caller</p>
+<h3 id="Notes"> Notes</h3> <p>If <code>set_constraint_handler_s</code> is never called, the default handler is implementation-defined: it may be <code>abort_handler_s</code>, <code>ignore_handler_s</code>, or some other implementation-defined handler.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#define __STDC_WANT_LIB_EXT1__ 1
+#include &lt;string.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+
+int main(void)
+{
+#ifdef __STDC_LIB_EXT1__
+ char dst[2];
+ set_constraint_handler_s(ignore_handler_s);
+ int r = strcpy_s(dst, sizeof dst, "Too long!");
+ printf("dst = \"%s\", r = %d\n", dst, r);
+ set_constraint_handler_s(abort_handler_s);
+ r = strcpy_s(dst, sizeof dst, "Too long!");
+ printf("dst = \"%s\", r = %d\n", dst, r);
+#endif
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">dst = "", r = 22
+abort_handler_s was called in response to a runtime-constraint violation.
+
+The runtime-constraint violation was caused by the following expression in strcpy_s:
+(s1max &lt;= (s2_len=strnlen_s(s2, s1max)) ) (in string_s.c:62)
+
+Note to end users: This program was terminated as a result
+of a bug present in the software. Please reach out to your
+software's vendor to get more help.
+Aborted</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul><li> K.3.6.1.2 The abort_handler_s function (p: 605) </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="ignore_handler_s" title="c/error/ignore handler s"> <span class="t-lines"><span>ignore_handler_s</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> ignore callback for the bounds-checked functions <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="set_constraint_handler_s" title="c/error/set constraint handler s"> <span class="t-lines"><span>set_constraint_handler_s</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> set the error callback for bounds-checked functions <br> <span class="t-mark">(function)</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/abort_handler_s" class="_attribution-link">https://en.cppreference.com/w/c/error/abort_handler_s</a>
+ </p>
+</div>