Files
hustoj/web/cppreference-zh/chmhelp/c-error-ignore_handler_s.html
2025-08-01 12:57:54 +08:00

152 lines
9.4 KiB
HTML

<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs" xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh">
<head><meta http-equiv="x-ua-compatible" content="ie=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ignore_handler_s</title>
<link rel="stylesheet" href="ext.css" />
<link rel="stylesheet" href="site_modules.css" />
</head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-c_error_ignore_handler_s skin-cppreference2 action-view cpp-navbar">
<div id="cpp-content-base">
<div id="content"><a id="top"></a>
<h1 id="firstHeading" class="firstHeading">ignore_handler_s</h1>
<div id="bodyContent">
<div id="contentSub"><span class="subpages">&lt; <a href="c.html">c</a>&lrm; | <a href="c-error.html">error</a></span></div>
<div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr" xml:lang="zh">
<table class="t-dcl-begin">
<tbody>
<tr class="t-dsc-header">
<td>
<div>&#23450;&#20041;&#20110;&#22836;&#25991;&#20214; <code>&lt;stdlib.h&gt;</code></div>
</td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl t-since-c11">
<td>
<div><span class="mw-geshi c source-c"><span class="kw4">void</span> ignore_handler_s<span class="br0">(</span> <span class="kw4">const</span> <span class="kw4">char</span> <span class="sy2">*</span> <span class="kw4">restrict</span> msg,<br /></span>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw4">void</span> <span class="sy2">*</span> <span class="kw4">restrict</span> ptr,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;errno_t error<br /></p>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">)</span><span class="sy4">;</span></div>
</td>
<td class="t-dcl-nopad"></td>
<td><span class="t-mark-rev t-since-c11">(C11 &#36215;)</span></td>
</tr>
<tr class="t-dcl-sep">
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>&#35813;&#20989;&#25968;&#20250;&#31616;&#21333;&#36820;&#22238;&#35843;&#29992;&#26041;&#65292;&#32780;&#19981;&#36827;&#34892;&#20219;&#20309;&#21160;&#20316;&#12290;</p>
<p>&#21487;&#20197;&#20256;&#36882;&#25351;&#21521;&#27492;&#20989;&#25968;&#30340;&#25351;&#38024;&#32473; <a href="c-error-set_constraint_handler_s.html">set_constraint_handler_s</a> &#20197;&#24314;&#31435;&#26080;&#20219;&#20309;&#21160;&#20316;&#30340;&#36816;&#34892;&#26102;&#21046;&#32422;&#36829;&#35268;&#22788;&#29702;&#12290;</p>
<dl>
<dd></dd>
<dd>&#21516;&#25152;&#26377;&#36793;&#30028;&#26816;&#26597;&#20989;&#25968;&#65292; <code>ignore_handler_s</code> &#20165;&#33509;&#23454;&#29616;&#23450;&#20041;&#20102; <span class="t-c"><span class="mw-geshi c source-c">__STDC_LIB_EXT1__</span></span> &#65292;&#19988;&#29992;&#25143;&#22312;&#21253;&#21547; <code>&lt;stdlib.h&gt;</code> &#21069;&#23450;&#20041; <span class="t-c"><span class="mw-geshi c source-c">__STDC_WANT_LIB_EXT1__</span></span> &#20026;&#25972;&#25968;&#24120;&#37327; <span class="t-c"><span class="mw-geshi c source-c"><span class="nu0">1</span></span></span> &#25165;&#20445;&#35777;&#21487;&#29992;&#12290;</dd>
</dl>
<h3><span class="mw-headline" id=".E5.8F.82.E6.95.B0">&#21442;&#25968;</span></h3>
<table class="t-par-begin">
<tr class="t-par">
<td>msg</td>
<td>-</td>
<td>&#25351;&#21521;&#25551;&#36848;&#38169;&#35823;&#30340;&#23383;&#31526;&#20018;&#30340;&#25351;&#38024;</td>
</tr>
<tr class="t-par">
<td>ptr</td>
<td>-</td>
<td>&#25351;&#21521;&#23454;&#29616;&#23450;&#20041;&#30340;&#23545;&#35937;&#30340;&#25351;&#38024;&#25110;&#31354;&#25351;&#38024;&#12290;&#23454;&#29616;&#23450;&#20041;&#23545;&#35937;&#30340;&#20363;&#23376;&#65292;&#26159;&#32473;&#20986;&#26816;&#27979;&#21040;&#36829;&#35268;&#30340;&#20989;&#25968;&#21517;&#21644;&#26816;&#27979;&#21040;&#36829;&#35268;&#26102;&#30340;&#34892;&#21495;&#30340;&#23545;&#35937;</td>
</tr>
<tr class="t-par">
<td>error</td>
<td>-</td>
<td>&#35201;&#30001;&#35843;&#29992;&#26041;&#20989;&#25968;&#36820;&#22238;&#30340;&#38169;&#35823;&#21495;&#65292;&#33509;&#23427;&#27491;&#22909;&#26159;&#36820;&#22238; <code>errno_t</code> &#30340;&#20989;&#25968;&#20043;&#19968;</td>
</tr>
</table>
<h3><span class="mw-headline" id=".E8.BF.94.E5.9B.9E.E5.80.BC">&#36820;&#22238;&#20540;</span></h3>
<p>&#65288;&#26080;&#65289;</p>
<h3><span class="mw-headline" id=".E6.B3.A8.E6.84.8F">&#27880;&#24847;</span></h3>
<p>&#33509;&#20197; <code>ignore_handler_s</code> &#20026;&#36816;&#34892;&#26102;&#21046;&#32422;&#36829;&#35268;&#22788;&#29702;&#20989;&#25968;&#65292;&#21017;&#21487;&#36890;&#36807;&#26816;&#39564;&#36793;&#30028;&#26816;&#26597;&#20989;&#25968;&#30340;&#35843;&#29992;&#32467;&#26524;&#26816;&#27979;&#36829;&#35268;&#65292;&#36825;&#23545;&#20110;&#19981;&#21516;&#20989;&#25968;&#21487;&#33021;&#19981;&#21516;&#65288;&#38750;&#38646; <span class="t-lc">errno_t</span> &#65292;&#20889;&#20837;&#21040;&#36755;&#20986;&#23383;&#31526;&#20018;&#30340;&#31354;&#23383;&#31526;&#31561;&#31561;&#65289;&#12290;</p>
<p>&#33509;&#20174;&#19981;&#35843;&#29992; <code>set_constraint_handler_s</code> &#65292;&#21017;&#40664;&#35748;&#22788;&#29702;&#26159;&#23454;&#29616;&#23450;&#20041;&#30340;&#65306;&#23427;&#21487;&#20197;&#26159; <span class="t-lc">abort_handler_s</span> &#12289; <span class="t-lc">ignore_handler_s</span> &#25110;&#21478;&#22806;&#30340;&#23454;&#29616;&#23450;&#20041;&#22788;&#29702;&#20989;&#25968;&#12290;</p>
<h3><span class="mw-headline" id=".E7.A4.BA.E4.BE.8B">&#31034;&#20363;</span></h3>
<div class="t-example">
<div class="t-example-live-link"></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;">
<div class="c source-c">
<pre class="de1"><span class="co2">#define __STDC_WANT_LIB_EXT1__ 1</span>
<span class="co2">#include &lt;string.h&gt;</span>
<span class="co2">#include &lt;stdio.h&gt;</span>
<span class="co2">#include &lt;stdlib.h&gt;</span>
<span class="kw4">int</span> main<span class="br0">(</span><span class="kw4">void</span><span class="br0">)</span>
<span class="br0">{</span>
<span class="co2">#ifdef __STDC_LIB_EXT1__</span>
<span class="kw4">char</span> dst<span class="br0">[</span><span class="nu0">2</span><span class="br0">]</span><span class="sy4">;</span>
set_constraint_handler_s<span class="br0">(</span>ignore_handler_s<span class="br0">)</span><span class="sy4">;</span>
<span class="kw4">int</span> r <span class="sy1">=</span> strcpy_s<span class="br0">(</span>dst, <span class="kw4">sizeof</span> dst, <span class="st0">&quot;Too long!&quot;</span><span class="br0">)</span><span class="sy4">;</span>
<a href="c-io-fprintf.html"><span class="kw851">printf</span></a><span class="br0">(</span><span class="st0">&quot;dst = <span class="es1">\&quot;</span>%s<span class="es1">\&quot;</span>, r = %d<span class="es1">\n</span>&quot;</span>, dst, r<span class="br0">)</span><span class="sy4">;</span>
set_constraint_handler_s<span class="br0">(</span>abort_handler_s<span class="br0">)</span><span class="sy4">;</span>
r <span class="sy1">=</span> strcpy_s<span class="br0">(</span>dst, <span class="kw4">sizeof</span> dst, <span class="st0">&quot;Too long!&quot;</span><span class="br0">)</span><span class="sy4">;</span>
<a href="c-io-fprintf.html"><span class="kw851">printf</span></a><span class="br0">(</span><span class="st0">&quot;dst = <span class="es1">\&quot;</span>%s<span class="es1">\&quot;</span>, r = %d<span class="es1">\n</span>&quot;</span>, dst, r<span class="br0">)</span><span class="sy4">;</span>
<span class="co2">#endif</span>
<span class="br0">}</span></pre></div>
</div>
<p>&#21487;&#33021;&#30340;&#36755;&#20986;&#65306;</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;">
<div class="text source-text">
<pre class="de1">dst = &quot;&quot;, 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&#39;s vendor to get more help.
Aborted</pre></div>
</div>
</div>
<h3><span class="mw-headline" id=".E5.BC.95.E7.94.A8">&#24341;&#29992;</span></h3>
<div class="t-ref-std-11">
<ul>
<li>C11 &#26631;&#20934;&#65288;ISO/IEC 9899:2011&#65289;&#65306;</li>
</ul>
<dl>
<dd>
<ul>
<li>K.3.6.1.3 The ignore_handler_s function (p: 606)</li>
</ul>
</dd>
</dl>
</div>
<h3><span class="mw-headline" id=".E5.8F.82.E9.98.85">&#21442;&#38405;</span></h3>
<table class="t-dsc-begin">
<tr class="t-dsc">
<td>
<div class="t-dsc-member-div">
<div><a href="c-error-abort_handler_s.html"><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>
</div>
</td>
<td>&#36793;&#30028;&#26816;&#26597;&#20989;&#25968;&#30340;&#24322;&#24120;&#20013;&#27490;&#22238;&#35843;<br />
<span class="t-mark">(&#20989;&#25968;)</span></td>
</tr>
<tr class="t-dsc">
<td>
<div class="t-dsc-member-div">
<div><a href="c-error-set_constraint_handler_s.html"><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>
</div>
</td>
<td>&#35774;&#32622;&#36793;&#30028;&#26816;&#26597;&#20989;&#25968;&#30340;&#20986;&#38169;&#22238;&#35843;<br />
<span class="t-mark">(&#20989;&#25968;)</span></td>
</tr>
</table>
</div>
<div class="visualClear"></div>
</div>
</div>
</div>
</body>
</html>