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
45
46
47
48
49
50
51
52
|
<h1 id="firstHeading" class="firstHeading">ignore_handler_s</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><stdlib.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c11"> <td> <pre data-language="c">void ignore_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>The function simply returns to the caller without performing any other action.</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 that does nothing. As with all bounds-checked functions, <code>ignore_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><stdlib.h></code>.</p>
<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> msg </td> <td> - </td> <td> pointer to character string that describes the error </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> the error about to be returned by the calling function, if it happens to be one of the functions that return errno_t </td>
</tr>
</table> <h3 id="Return_value"> Return value</h3> <p>(none)</p>
<h3 id="Notes"> Notes</h3> <p>If <code>ignore_handler_s</code> is used as a the runtime constraints handler, the violations may be detected by examining the results of the bounds-checked function calls, which may be different for different functions (non-zero <code>errno_t</code>, null character written to the first byte of the output string, etc)</p>
<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 <string.h>
#include <stdio.h>
#include <stdlib.h>
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 <= (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.3 The ignore_handler_s function (p: 606) </li></ul>
</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="abort_handler_s" title="c/error/abort handler s"> <span class="t-lines"><span>abort_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> abort 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">
© cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
<a href="https://en.cppreference.com/w/c/error/ignore_handler_s" class="_attribution-link">https://en.cppreference.com/w/c/error/ignore_handler_s</a>
</p>
</div>
|