{"id":104919,"date":"2026-09-13T12:41:12","date_gmt":"2026-09-13T04:41:12","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/104919.html"},"modified":"2026-09-13T12:41:12","modified_gmt":"2026-09-13T04:41:12","slug":"%e6%9c%89%e7%ac%a6%e5%8f%b7%e6%97%a0%e7%ac%a6%e5%8f%b7%e6%af%94%e5%a4%a7%e5%b0%8f%e5%bc%82%e5%b8%b8%ef%bc%9a%e6%b7%b7%e6%af%94%e8%a7%a6%e5%8f%91%e9%9a%90%e5%bc%8f%e8%bd%ac%e6%97%a0%e7%ac%a6%e5%8f%b7","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/104919.html","title":{"rendered":"\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38\uff1a\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7\uff0c\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83"},"content":{"rendered":"<h2>\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38&#xff1a;\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7&#xff0c;\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83<\/h2>\n<p>\u6458\u8981&#xff1a;C \u8bed\u8a00\u4e2d&#xff0c;\u6709\u7b26\u53f7\u6570\u4e0e\u65e0\u7b26\u53f7\u6570\u6df7\u5408\u6bd4\u8f83\u65f6&#xff0c;\u6709\u7b26\u53f7\u6570\u4f1a\u88ab\u9690\u5f0f\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7\u6570&#xff0c;\u5bfc\u81f4\u8d1f\u6570&#xff08;\u5982 -1&#xff09;\u53d8\u6210\u8d85\u5927\u6b63\u6570&#xff08;0xFFFFFFFF&#xff09;&#xff0c;\u6bd4\u8f83\u7ed3\u679c\u5b8c\u5168\u53cd\u76f4\u89c9&#xff0c;\u8d1f\u6570\u88ab\u5f53\u4f5c\u5927\u6b63\u6570\u653e\u884c&#xff0c;\u5f15\u53d1\u8d8a\u754c\u8bbf\u95ee\u7b49\u9690\u60a3\u3002\u672c\u6587\u901a\u8fc7\u771f\u5b9e\u7ffb\u8f66\u73b0\u573a\u3001C \u7684\u5bfb\u5e38\u7b97\u672f\u8f6c\u6362\u539f\u7406\u3001\u9519\u8bef\u4ee3\u7801\u5256\u6790&#xff0c;\u7ed9\u51fa\u300c\u5148\u5224\u8d1f &#043; \u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83\u300d\u7684\u6b63\u786e\u89e3\u6cd5&#xff0c;\u5e76\u914d\u5957 -Wsign-compare \u7f16\u8bd1\u8b66\u544a\u4e0e\u6700\u4f73\u5b9e\u8df5\u6e05\u5355&#xff0c;\u5e2e\u4f60\u5f7b\u5e95\u907f\u5f00\u6df7\u6bd4\u9677\u9631\u3002<\/p>\n<h3>\u4e00\u3001\u5f00\u7bc7&#xff1a;\u4e00\u4e2a\u771f\u5b9e\u7ffb\u8f66\u73b0\u573a<\/h3>\n<p>\u4e00\u6bb5\u4ee3\u7801\u6bd4\u8f83\u4e24\u4e2a\u957f\u5ea6&#xff1a;int len &#061; read_len(); \u548c uint32_t max &#061; 256;&#xff0c;\u5224\u65ad if (len &lt; max) \u672c\u610f&#034;\u957f\u5ea6\u4e3a\u8d1f\u6216\u8d85 max \u90fd\u62d2\u7edd&#034;\u3002\u4f46\u53d1\u73b0&#xff1a;\u5f53 len \u4e3a\u8d1f\u6570&#xff08;\u5982 -1 \u8868\u793a\u8bfb\u9519&#xff09;\u65f6&#xff0c;if (len &lt; max) \u5c45\u7136\u4e3a false&#xff0c;\u8d1f\u6570\u88ab\u653e\u8fdb\u4e86\u540e\u7eed\u5904\u7406 \u2192 \u8d8a\u754c\u8bbf\u95ee\u3002<\/p>\n<p>\u539f\u56e0&#xff1a;C \u8bed\u8a00\u91cc\u6709\u7b26\u53f7\u4e0e\u65e0\u7b26\u53f7\u6bd4\u8f83&#xff0c;\u6709\u7b26\u53f7\u6570\u4f1a\u88ab\u9690\u5f0f\u8f6c\u6362\u6210\u65e0\u7b26\u53f7\u3002-1 \u53d8\u6210 0xFFFFFFFF&#xff08;\u8d85\u5927\u6b63\u6570&#xff09;&#xff0c;\u8fdc\u5927\u4e8e max&#061;256 \u2192 len &lt; max \u4e3a false \u2192 \u6f0f\u68c0\u8d1f\u6570\u3002<\/p>\n<p>\u6839\u56e0\u4e00\u53e5\u8bdd&#xff1a;C \u4e2d&#034;\u6709\u7b26\u53f7 vs \u65e0\u7b26\u53f7&#034;\u6df7\u5408\u6bd4\u8f83\/\u8fd0\u7b97\u65f6&#xff0c;\u6709\u7b26\u53f7\u6570\u4f1a\u9690\u5f0f\u63d0\u5347\u4e3a\u65e0\u7b26\u53f7&#xff08;C \u7684&#034;\u5bfb\u5e38\u7b97\u672f\u8f6c\u6362&#034;\u89c4\u5219&#xff09;\u3002\u8d1f\u6570\u53d8\u8d85\u5927\u6b63\u6570&#xff0c;\u6bd4\u8f83\u7ed3\u679c\u5b8c\u5168\u53cd\u76f4\u89c9\u3002\u89e3\u6cd5&#xff1a;\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83\u2014\u2014\u8981\u4e48\u90fd\u8f6c\u6709\u7b26\u53f7&#xff08;\u4e14\u5148\u5224\u975e\u8d1f&#xff09;&#xff0c;\u8981\u4e48\u90fd\u7528\u65e0\u7b26\u53f7\u5e76\u5bf9\u8d1f\u6570\u5355\u72ec\u5904\u7406&#xff0c;\u675c\u7edd\u9690\u5f0f\u6df7\u6bd4\u3002<\/p>\n<p>\u9002\u7528\u8bfb\u8005&#xff1a;\u5199 if (a &lt; b) \u5176\u4e2d a \u662f int\u3001b \u662f uint32&#xff0c;\u51fa\u73b0&#034;\u8d1f\u6570\u6bd4\u8f83\u53cd\u5e38&#034;\u7684\u540c\u5b66\u3002<br \/>\n\u8bfb\u5b8c\u4f60\u80fd\u505a&#xff1a;\u8bc6\u522b\u6709\u7b26\u53f7\/\u65e0\u7b26\u53f7\u6df7\u6bd4\u9677\u9631&#xff0c;\u7edf\u4e00\u7c7b\u578b\u6216\u62c6\u5206\u5224\u65ad&#xff0c;\u907f\u514d\u8d1f\u6570\u88ab\u5f53\u5927\u6b63\u6570\u653e\u8fc7\u3002<\/p>\n<h3>\u4e8c\u3001\u5148\u641e\u61c2&#xff1a;C \u7684\u5bfb\u5e38\u7b97\u672f\u8f6c\u6362&#xff08;\u8ba4\u77e5&#xff09;<\/h3>\n<h4>2.1 \u6df7\u6bd4\u65f6\u53d1\u751f\u4ec0\u4e48<\/h4>\n<p>\u5f53\u8868\u8fbe\u5f0f\u91cc\u540c\u65f6\u6709\u7b26\u53f7\u548c\u65e0\u7b26\u53f7\u64cd\u4f5c\u6570&#xff08;\u4e14\u65e0\u7b26\u53f7\u7c7b\u578b&#034;\u79e9&#034;\u4e0d\u4f4e\u4e8e\u6709\u7b26\u53f7&#xff09;&#xff0c;\u6709\u7b26\u53f7\u64cd\u4f5c\u6570\u88ab\u8f6c\u6362\u6210\u65e0\u7b26\u53f7\u3002\u4e8e\u662f int -1 \u5728\u6bd4\u8f83\u65f6\u53d8\u6210 unsigned 0xFFFFFFFF&#xff0c;\u6bd4\u4efb\u4f55\u6b63\u5e38\u6b63\u6570\u90fd\u5927\u3002<\/p>\n<h4>2.2 \u4e3a\u4ec0\u4e48\u5371\u9669<\/h4>\n<p>\u5f88\u591a\u4e1a\u52a1\u903b\u8f91\u7528\u8d1f\u6570\u8868\u793a&#034;\u9519\u8bef\u7801&#034;&#xff08;\u5982 -1&#xff09;\u3002\u4e00\u65e6\u548c\u65e0\u7b26\u53f7\u6bd4\u8f83&#xff0c;\u8d1f\u6570\u53d8\u8d85\u5927\u6b63\u6570 \u2192 \u672c\u8be5\u62e6\u622a\u7684\u975e\u6cd5\u503c\u88ab\u653e\u884c \u2192 \u8d8a\u754c\/\u5d29\u6e83\u3002<\/p>\n<table>\n<tr>\u6bd4\u8f83\u7ed3\u679c<\/tr>\n<tbody>\n<tr>\n<td>int -1 &lt; uint 256&#xff08;\u6df7\u6bd4&#xff09;<\/td>\n<td>false&#xff08;\u9519&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>(int)-1 &lt; (int)256&#xff08;\u540c\u53f7&#xff09;<\/td>\n<td>true&#xff08;\u5bf9&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>#mermaid-svg-MVGSSTJFd7Ml8qqb{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-MVGSSTJFd7Ml8qqb .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-MVGSSTJFd7Ml8qqb .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-MVGSSTJFd7Ml8qqb .error-icon{fill:#552222;}#mermaid-svg-MVGSSTJFd7Ml8qqb .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-MVGSSTJFd7Ml8qqb .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-MVGSSTJFd7Ml8qqb .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-MVGSSTJFd7Ml8qqb .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-MVGSSTJFd7Ml8qqb .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-MVGSSTJFd7Ml8qqb .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-MVGSSTJFd7Ml8qqb .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-MVGSSTJFd7Ml8qqb .marker{fill:#333333;stroke:#333333;}#mermaid-svg-MVGSSTJFd7Ml8qqb .marker.cross{stroke:#333333;}#mermaid-svg-MVGSSTJFd7Ml8qqb svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-MVGSSTJFd7Ml8qqb p{margin:0;}#mermaid-svg-MVGSSTJFd7Ml8qqb .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-MVGSSTJFd7Ml8qqb .cluster-label text{fill:#333;}#mermaid-svg-MVGSSTJFd7Ml8qqb .cluster-label span{color:#333;}#mermaid-svg-MVGSSTJFd7Ml8qqb .cluster-label span p{background-color:transparent;}#mermaid-svg-MVGSSTJFd7Ml8qqb .label text,#mermaid-svg-MVGSSTJFd7Ml8qqb span{fill:#333;color:#333;}#mermaid-svg-MVGSSTJFd7Ml8qqb .node rect,#mermaid-svg-MVGSSTJFd7Ml8qqb .node circle,#mermaid-svg-MVGSSTJFd7Ml8qqb .node ellipse,#mermaid-svg-MVGSSTJFd7Ml8qqb .node polygon,#mermaid-svg-MVGSSTJFd7Ml8qqb .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-MVGSSTJFd7Ml8qqb .rough-node .label text,#mermaid-svg-MVGSSTJFd7Ml8qqb .node .label text,#mermaid-svg-MVGSSTJFd7Ml8qqb .image-shape .label,#mermaid-svg-MVGSSTJFd7Ml8qqb .icon-shape .label{text-anchor:middle;}#mermaid-svg-MVGSSTJFd7Ml8qqb .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-MVGSSTJFd7Ml8qqb .rough-node .label,#mermaid-svg-MVGSSTJFd7Ml8qqb .node .label,#mermaid-svg-MVGSSTJFd7Ml8qqb .image-shape .label,#mermaid-svg-MVGSSTJFd7Ml8qqb .icon-shape .label{text-align:center;}#mermaid-svg-MVGSSTJFd7Ml8qqb .node.clickable{cursor:pointer;}#mermaid-svg-MVGSSTJFd7Ml8qqb .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-MVGSSTJFd7Ml8qqb .arrowheadPath{fill:#333333;}#mermaid-svg-MVGSSTJFd7Ml8qqb .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-MVGSSTJFd7Ml8qqb .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-MVGSSTJFd7Ml8qqb .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-MVGSSTJFd7Ml8qqb .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-MVGSSTJFd7Ml8qqb .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-MVGSSTJFd7Ml8qqb .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-MVGSSTJFd7Ml8qqb .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-MVGSSTJFd7Ml8qqb .cluster text{fill:#333;}#mermaid-svg-MVGSSTJFd7Ml8qqb .cluster span{color:#333;}#mermaid-svg-MVGSSTJFd7Ml8qqb div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-MVGSSTJFd7Ml8qqb .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-MVGSSTJFd7Ml8qqb rect.text{fill:none;stroke-width:0;}#mermaid-svg-MVGSSTJFd7Ml8qqb .icon-shape,#mermaid-svg-MVGSSTJFd7Ml8qqb .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-MVGSSTJFd7Ml8qqb .icon-shape p,#mermaid-svg-MVGSSTJFd7Ml8qqb .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-MVGSSTJFd7Ml8qqb .icon-shape rect,#mermaid-svg-MVGSSTJFd7Ml8qqb .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-MVGSSTJFd7Ml8qqb .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-MVGSSTJFd7Ml8qqb .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-MVGSSTJFd7Ml8qqb :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u6df7\u6bd4 \u9690\u8f6c\u65e0\u7b26\u53f7<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u90fd\u8f6c\u6709\u7b26\u53f7<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>int a \u4e0e uint b \u6bd4<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u7c7b\u578b\u7edf\u4e00?<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>a\u8d1f\u6570\u53d8\u8d85\u5927 \u6bd4\u8f83\u53cd<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u6b63\u5e38<\/p>\n<p><\/span><\/p>\n<p>\u56fe 1&#xff1a;\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6df7\u6bd4&#xff08;\u5982\u56fe 1 \u6240\u793a&#xff0c;\u9690\u8f6c\u65e0\u7b26\u53f7\u81f4\u8d1f\u6570\u53d8\u8d85\u5927&#xff09;\u3002<\/p>\n<p>[\u6ce8\u610f] \u8f6c\u6362\u89c4\u5219\u8fd8\u548c\u7c7b\u578b\u5bbd\u5ea6\u6709\u5173&#xff08;\u5982 int \u4e0e unsigned int \u540c\u5bbd\u5219\u8f6c\u65e0\u7b26\u53f7&#xff1b;int \u4e0e unsigned long long \u4e5f\u8f6c\u65e0\u7b26\u53f7&#xff09;\u3002\u7f16\u8bd1\u5668\u5e38\u5f00 -Wsign-compare \u8b66\u544a&#xff0c;\u52a1\u5fc5\u6253\u5f00\u3002<\/p>\n<h3>\u4e09\u3001\u4e3a\u4ec0\u4e48\u53cd\u5e38&#xff08;\u539f\u7406 &#043; \u771f\u5b9e\u9519\u8bef\u4ee3\u7801&#xff09;<\/h3>\n<h4>3.1 \u9519\u8bef\u7248<\/h4>\n<p><span class=\"token comment\">\/\/ \u274c \u9519&#xff1a;int \u4e0e uint \u6df7\u6bd4<\/span><br \/>\n<span class=\"token keyword\">int<\/span> len <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">read_len<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>                 <span class=\"token comment\">\/\/ \u8bfb\u9519\u8fd4\u56de -1<\/span><br \/>\n<span class=\"token class-name\">uint32_t<\/span> max <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">256<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>len <span class=\"token operator\">&lt;<\/span> max<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>                      <span class=\"token comment\">\/\/ len&#061;-1 \u88ab\u8f6c\u65e0\u7b26\u53f7&#061;0xFFFFFFFF &gt; 256 \u2192 false<\/span><br \/>\n    <span class=\"token function\">process<\/span><span class=\"token punctuation\">(<\/span>len<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>                     <span class=\"token comment\">\/\/ \u8d1f\u6570\u88ab\u653e\u884c&#xff01;\u8d8a\u754c<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u9519&#xff1a;\u2460len&#061;-1&#xff1b;\u2461\u4e0e uint32_t max \u6bd4\u8f83&#xff0c;\u9690\u8f6c\u65e0\u7b26\u53f7 0xFFFFFFFF&#xff1b;\u24620xFFFFFFFF &lt; 256 \u4e3a false \u2192 \u8d1f\u6570\u6f0f\u68c0&#xff1b;\u2463process(-1) \u8d8a\u754c\u8bbf\u95ee\u3002<\/p>\n<p>[\u5751] \u94c1\u5f8b&#xff1a;\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6df7\u6bd4&#xff0c;\u8d1f\u6570\u53d8\u8d85\u5927\u6b63\u6570\u3002\u6bd4\u8f83\u524d\u7edf\u4e00\u7c7b\u578b&#xff0c;\u8d1f\u6570\u5148\u5355\u72ec\u5224\u3002<\/p>\n<h4>3.2 \u4e3a\u4ec0\u4e48&#034;\u770b\u4f3c\u6b63\u5e38&#034;<\/h4>\n<p>\u53ea\u6709 len \u4e3a\u8d1f\u624d\u66b4\u9732&#xff1b;\u6b63\u5e38\u6b63\u6570\u533a\u95f4\u6bd4\u8f83\u7ed3\u679c&#034;\u6070\u597d\u5bf9&#034;&#xff0c;\u63a9\u76d6\u4e86\u9690\u60a3 \u2192 \u5076\u53d1&#xff08;\u8bfb\u9519\u65f6\u624d\u5d29&#xff09;\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u9519\u8bef\u4ee3\u7801\u7684\u6267\u884c\u6d41\u7a0b&#xff0c;\u53ef\u4ee5\u770b\u5230\u8d1f\u6570\u5982\u4f55\u88ab\u9690\u5f0f\u8f6c\u6362\u540e\u6f0f\u68c0&#xff1a;<\/p>\n<p>#mermaid-svg-6aTbkZzrQ6NhVP47{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-6aTbkZzrQ6NhVP47 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-6aTbkZzrQ6NhVP47 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-6aTbkZzrQ6NhVP47 .error-icon{fill:#552222;}#mermaid-svg-6aTbkZzrQ6NhVP47 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-6aTbkZzrQ6NhVP47 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-6aTbkZzrQ6NhVP47 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-6aTbkZzrQ6NhVP47 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-6aTbkZzrQ6NhVP47 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-6aTbkZzrQ6NhVP47 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-6aTbkZzrQ6NhVP47 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-6aTbkZzrQ6NhVP47 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-6aTbkZzrQ6NhVP47 .marker.cross{stroke:#333333;}#mermaid-svg-6aTbkZzrQ6NhVP47 svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-6aTbkZzrQ6NhVP47 p{margin:0;}#mermaid-svg-6aTbkZzrQ6NhVP47 .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-6aTbkZzrQ6NhVP47 .cluster-label text{fill:#333;}#mermaid-svg-6aTbkZzrQ6NhVP47 .cluster-label span{color:#333;}#mermaid-svg-6aTbkZzrQ6NhVP47 .cluster-label span p{background-color:transparent;}#mermaid-svg-6aTbkZzrQ6NhVP47 .label text,#mermaid-svg-6aTbkZzrQ6NhVP47 span{fill:#333;color:#333;}#mermaid-svg-6aTbkZzrQ6NhVP47 .node rect,#mermaid-svg-6aTbkZzrQ6NhVP47 .node circle,#mermaid-svg-6aTbkZzrQ6NhVP47 .node ellipse,#mermaid-svg-6aTbkZzrQ6NhVP47 .node polygon,#mermaid-svg-6aTbkZzrQ6NhVP47 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-6aTbkZzrQ6NhVP47 .rough-node .label text,#mermaid-svg-6aTbkZzrQ6NhVP47 .node .label text,#mermaid-svg-6aTbkZzrQ6NhVP47 .image-shape .label,#mermaid-svg-6aTbkZzrQ6NhVP47 .icon-shape .label{text-anchor:middle;}#mermaid-svg-6aTbkZzrQ6NhVP47 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-6aTbkZzrQ6NhVP47 .rough-node .label,#mermaid-svg-6aTbkZzrQ6NhVP47 .node .label,#mermaid-svg-6aTbkZzrQ6NhVP47 .image-shape .label,#mermaid-svg-6aTbkZzrQ6NhVP47 .icon-shape .label{text-align:center;}#mermaid-svg-6aTbkZzrQ6NhVP47 .node.clickable{cursor:pointer;}#mermaid-svg-6aTbkZzrQ6NhVP47 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-6aTbkZzrQ6NhVP47 .arrowheadPath{fill:#333333;}#mermaid-svg-6aTbkZzrQ6NhVP47 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-6aTbkZzrQ6NhVP47 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-6aTbkZzrQ6NhVP47 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-6aTbkZzrQ6NhVP47 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-6aTbkZzrQ6NhVP47 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-6aTbkZzrQ6NhVP47 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-6aTbkZzrQ6NhVP47 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-6aTbkZzrQ6NhVP47 .cluster text{fill:#333;}#mermaid-svg-6aTbkZzrQ6NhVP47 .cluster span{color:#333;}#mermaid-svg-6aTbkZzrQ6NhVP47 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-6aTbkZzrQ6NhVP47 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-6aTbkZzrQ6NhVP47 rect.text{fill:none;stroke-width:0;}#mermaid-svg-6aTbkZzrQ6NhVP47 .icon-shape,#mermaid-svg-6aTbkZzrQ6NhVP47 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-6aTbkZzrQ6NhVP47 .icon-shape p,#mermaid-svg-6aTbkZzrQ6NhVP47 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-6aTbkZzrQ6NhVP47 .icon-shape rect,#mermaid-svg-6aTbkZzrQ6NhVP47 .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-6aTbkZzrQ6NhVP47 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-6aTbkZzrQ6NhVP47 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-6aTbkZzrQ6NhVP47 :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u662f&#xff08;\u5982 -1&#xff09;<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/p>\n<p>false&#xff08;\u9519&#xff09;<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u5426&#xff08;\u6b63\u6570&#xff09;<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>int len &#061; read_len()<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>len &lt; 0 ?<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>len \u9690\u5f0f\u8f6c unsigned 0xFFFFFFFF<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>0xFFFFFFFF &lt; 256 ?<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u8d1f\u6570\u88ab\u653e\u884c<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>process(-1) \u8d8a\u754c\u8bbf\u95ee<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u6b63\u5e38\u6bd4\u8f83<\/p>\n<p><\/span><\/p>\n<p>\u56fe 2&#xff1a;\u9519\u8bef\u7248\u6267\u884c\u6d41\u7a0b&#xff08;\u8d1f\u6570\u7ecf\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7\u540e\u6f0f\u68c0&#xff09;\u3002<\/p>\n<h3>\u56db\u3001\u6b63\u786e\u89e3\u6cd5&#xff1a;\u7edf\u4e00\u7c7b\u578b &#043; \u5148\u5224\u8d1f&#xff08;\u5b8c\u6574\u843d\u5730&#xff09;<\/h3>\n<h4>4.1 \u65b9\u6848\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u65b9\u6848\u8d1f\u6570\u5b89\u5168\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u6df7\u6bd4<\/td>\n<td>\u6f0f\u8d1f<\/td>\n<td>\u9519<\/td>\n<\/tr>\n<tr>\n<td>\u5148\u5224\u8d1f&#043;\u540c\u53f7\u6bd4<\/td>\n<td>\u5b89\u5168<\/td>\n<td>\u6b63\u89e3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4.2 \u914d\u7f6e&#xff08;\u7167\u7740\u70b9&#xff09;<\/h4>\n<p>\u5f00\u7f16\u8bd1\u8b66\u544a -Wsign-compare&#xff08;GCC&#xff09;&#xff0c;\u6df7\u6bd4\u4f1a\u88ab\u8b66\u544a\u3002<\/p>\n<h4>4.3 \u5b8c\u6574\u4ee3\u7801<\/h4>\n<p><span class=\"token comment\">\/\/ \u2705 \u6b63\u786e&#xff1a;\u5148\u5224\u8d1f&#xff0c;\u518d\u7528\u540c\u53f7\u6bd4\u8f83<\/span><br \/>\n<span class=\"token keyword\">int<\/span> len <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">read_len<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>                  <span class=\"token comment\">\/\/ -1 \u8868\u793a\u9519<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>len <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token function\">handle_error<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">return<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span>          <span class=\"token comment\">\/\/ \u8d1f\u6570\u5355\u72ec\u62e6<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">uint32_t<\/span><span class=\"token punctuation\">)<\/span>len <span class=\"token operator\">&lt;<\/span> max<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>            <span class=\"token comment\">\/\/ \u90fd\u65e0\u7b26\u53f7&#xff0c;\u8bed\u4e49\u6e05\u6670<\/span><br \/>\n    <span class=\"token function\">process<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">uint32_t<\/span><span class=\"token punctuation\">)<\/span>len<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token comment\">\/\/ \u6216\u90fd\u7528\u6709\u7b26\u53f7&#xff08;max \u4e0d\u8d85\u8fc7 INT_MAX \u65f6&#xff09;<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>len <span class=\"token operator\">&gt;&#061;<\/span> <span class=\"token number\">0<\/span> <span class=\"token operator\">&amp;&amp;<\/span> len <span class=\"token operator\">&lt;<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span><span class=\"token punctuation\">)<\/span>max<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token function\">process<\/span><span class=\"token punctuation\">(<\/span>len<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p>[\u5751] \u4e24\u4e2a\u7ffb\u8f66\u70b9\u6536\u597d&#xff1a;<\/p>\n<li>int \u4e0e uint \u76f4\u63a5\u6bd4\u8f83\u2014\u2014\u8d1f\u6570\u6f0f\u68c0\u6839\u56e0&#xff1b;\u7edf\u4e00\u7c7b\u578b\/\u5148\u5224\u8d1f\u3002<\/li>\n<li>\u5ffd\u7565 -Wsign-compare \u8b66\u544a\u2014\u2014\u9690\u60a3\u6f5c\u4f0f&#xff1b;\u5f00\u8b66\u544a\u5e76\u4fee\u6389\u6240\u6709\u6df7\u6bd4\u3002<\/li>\n<h4>4.4 \u6539\u5b8c\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u6307\u6807\u6539\u524d\u6539\u540e<\/tr>\n<tbody>\n<tr>\n<td>len&#061;-1 \u6bd4\u8f83<\/td>\n<td>\u653e\u884c&#xff08;\u9519&#xff09;<\/td>\n<td>\u62e6\u622a<\/td>\n<\/tr>\n<tr>\n<td>\u8d1f\u6570\u8d8a\u754c<\/td>\n<td>\u6709<\/td>\n<td>\u65e0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e0b\u9762\u662f\u6b63\u786e\u89e3\u6cd5\u7684\u5224\u65ad\u6d41\u7a0b&#xff0c;\u5148\u5224\u8d1f\u518d\u7edf\u4e00\u7c7b\u578b\u6bd4\u8f83&#xff1a;<\/p>\n<p>#mermaid-svg-MI7IcgBIQDLNtFIx{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-MI7IcgBIQDLNtFIx .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-MI7IcgBIQDLNtFIx .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-MI7IcgBIQDLNtFIx .error-icon{fill:#552222;}#mermaid-svg-MI7IcgBIQDLNtFIx .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-MI7IcgBIQDLNtFIx .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-MI7IcgBIQDLNtFIx .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-MI7IcgBIQDLNtFIx .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-MI7IcgBIQDLNtFIx .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-MI7IcgBIQDLNtFIx .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-MI7IcgBIQDLNtFIx .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-MI7IcgBIQDLNtFIx .marker{fill:#333333;stroke:#333333;}#mermaid-svg-MI7IcgBIQDLNtFIx .marker.cross{stroke:#333333;}#mermaid-svg-MI7IcgBIQDLNtFIx svg{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-MI7IcgBIQDLNtFIx p{margin:0;}#mermaid-svg-MI7IcgBIQDLNtFIx .label{font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;color:#333;}#mermaid-svg-MI7IcgBIQDLNtFIx .cluster-label text{fill:#333;}#mermaid-svg-MI7IcgBIQDLNtFIx .cluster-label span{color:#333;}#mermaid-svg-MI7IcgBIQDLNtFIx .cluster-label span p{background-color:transparent;}#mermaid-svg-MI7IcgBIQDLNtFIx .label text,#mermaid-svg-MI7IcgBIQDLNtFIx span{fill:#333;color:#333;}#mermaid-svg-MI7IcgBIQDLNtFIx .node rect,#mermaid-svg-MI7IcgBIQDLNtFIx .node circle,#mermaid-svg-MI7IcgBIQDLNtFIx .node ellipse,#mermaid-svg-MI7IcgBIQDLNtFIx .node polygon,#mermaid-svg-MI7IcgBIQDLNtFIx .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-MI7IcgBIQDLNtFIx .rough-node .label text,#mermaid-svg-MI7IcgBIQDLNtFIx .node .label text,#mermaid-svg-MI7IcgBIQDLNtFIx .image-shape .label,#mermaid-svg-MI7IcgBIQDLNtFIx .icon-shape .label{text-anchor:middle;}#mermaid-svg-MI7IcgBIQDLNtFIx .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-MI7IcgBIQDLNtFIx .rough-node .label,#mermaid-svg-MI7IcgBIQDLNtFIx .node .label,#mermaid-svg-MI7IcgBIQDLNtFIx .image-shape .label,#mermaid-svg-MI7IcgBIQDLNtFIx .icon-shape .label{text-align:center;}#mermaid-svg-MI7IcgBIQDLNtFIx .node.clickable{cursor:pointer;}#mermaid-svg-MI7IcgBIQDLNtFIx .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-MI7IcgBIQDLNtFIx .arrowheadPath{fill:#333333;}#mermaid-svg-MI7IcgBIQDLNtFIx .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-MI7IcgBIQDLNtFIx .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-MI7IcgBIQDLNtFIx .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-MI7IcgBIQDLNtFIx .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-MI7IcgBIQDLNtFIx .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-MI7IcgBIQDLNtFIx .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-MI7IcgBIQDLNtFIx .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-MI7IcgBIQDLNtFIx .cluster text{fill:#333;}#mermaid-svg-MI7IcgBIQDLNtFIx .cluster span{color:#333;}#mermaid-svg-MI7IcgBIQDLNtFIx div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-MI7IcgBIQDLNtFIx .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-MI7IcgBIQDLNtFIx rect.text{fill:none;stroke-width:0;}#mermaid-svg-MI7IcgBIQDLNtFIx .icon-shape,#mermaid-svg-MI7IcgBIQDLNtFIx .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-MI7IcgBIQDLNtFIx .icon-shape p,#mermaid-svg-MI7IcgBIQDLNtFIx .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-MI7IcgBIQDLNtFIx .icon-shape rect,#mermaid-svg-MI7IcgBIQDLNtFIx .image-shape rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-MI7IcgBIQDLNtFIx .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-MI7IcgBIQDLNtFIx .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-MI7IcgBIQDLNtFIx :root{&#8211;mermaid-font-family:\\&#8221;trebuchet ms\\&#8221;,verdana,arial,sans-serif;}<span class=\"edgeLabel\"><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u662f<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u5426<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u662f<\/p>\n<p><\/span><span class=\"edgeLabel\"><\/p>\n<p>\u5426<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>int len &#061; read_len()<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>len &lt; 0 ?<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>handle_error() \u62e6\u622a<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>(uint32_t)len &lt; max ?<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>process(len) \u5b89\u5168\u5904\u7406<\/p>\n<p><\/span><span class=\"nodeLabel\"><\/p>\n<p>\u8d85\u9650\u62d2\u7edd<\/p>\n<p><\/span><\/p>\n<p>\u56fe 3&#xff1a;\u6b63\u786e\u7248\u6267\u884c\u6d41\u7a0b&#xff08;\u5148\u5224\u8d1f&#xff0c;\u518d\u7edf\u4e00\u7c7b\u578b\u6bd4\u8f83&#xff09;\u3002<\/p>\n<h3>\u4e94\u3001\u6536\u5c3e<\/h3>\n<p>\u8981\u70b9\u590d\u76d8<\/p>\n<li>\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6df7\u6bd4&#xff0c;\u8d1f\u6570\u9690\u8f6c\u65e0\u7b26\u53f7\u53d8\u8d85\u5927&#xff0c;\u6bd4\u8f83\u53cd\u76f4\u89c9\u3002<\/li>\n<li>\u6bd4\u8f83\u524d\u7edf\u4e00\u7c7b\u578b&#xff0c;\u8d1f\u6570\u5148\u5355\u72ec\u5224&#xff0c;\u522b\u6df7\u6bd4\u3002<\/li>\n<li>\u5f00 -Wsign-compare \u63d0\u524d\u6293\u6df7\u6bd4\u3002<\/li>\n<p>\u6700\u4f73\u5b9e\u8df5\u6e05\u5355<\/p>\n<ul>\n<li>\u6bd4\u8f83\u524d\u786e\u4fdd\u4e24\u4fa7\u540c\u7b26\u53f7\u7c7b\u578b&#xff1b;\u8d1f\u6570\u8bed\u4e49\u5148\u5355\u72ec\u5904\u7406\u3002<\/li>\n<li>\u957f\u5ea6\/\u7d22\u5f15\u7528 size_t\/\u65e0\u7b26\u53f7\u65f6&#xff0c;\u8d1f\u6570\u9519\u8bef\u7801\u6539\u7528\u5355\u72ec\u6807\u5fd7\u6216\u4e0d\u540c\u53d8\u91cf\u3002<\/li>\n<li>\u5f00 -Wsign-compare -Wconversion \u8b66\u544a\u5e76\u6e05\u96f6\u3002<\/li>\n<li>\u6570\u7ec4\u7d22\u5f15\u7528\u65e0\u7b26\u53f7&#xff0c;\u4f46\u8bfb\u5165\u503c\u5148\u5728\u6709\u7b26\u53f7\u57df\u5224\u8303\u56f4\u518d\u8f6c\u3002<\/li>\n<li>\u4ee3\u7801\u5ba1\u67e5\u91cd\u70b9\u67e5 if (int_x &lt; uint_y) \u5f62\u5f0f\u3002<\/li>\n<\/ul>\n<p>\u8fdb\u9636\u5ef6\u4f38&#xff1a;C23 \u6709 _BitInt\/\u66f4\u4e25\u683c\u7c7b\u578b&#xff1b;\u9759\u6001\u5206\u6790&#xff08;PC-lint\u3001Cppcheck&#xff09;\u80fd\u6293\u6df7\u6bd4\u3002\u5927\u578b\u9879\u76ee\u7edf\u4e00&#034;\u7d22\u5f15\u7528 size_t\u3001\u9519\u8bef\u7528\u8d1f\u7801\u5206\u53d8\u91cf&#034;\u7684\u7f16\u7801\u89c4\u8303\u3002<\/p>\n<p>\u4e92\u52a8&#xff1a;\u4f60\u7c7b\u578b\u6df7\u6bd4\u8fd8\u8e29\u8fc7\u5565&#xff1f;size_t \u4e0e int \u5faa\u73af\u6bd4\u8f83\u3001uint8 \u4e0e int \u8fd0\u7b97\u56de\u7ed5&#xff1f;\u8bc4\u8bba\u533a\u804a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38&#xff1a;\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7&#xff0c;\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83\u6458\u8981&#xff1a;C \u8bed\u8a00\u4e2d&#xff0c;\u6709\u7b26\u53f7\u6570\u4e0e\u65e0\u7b26\u53f7\u6570\u6df7\u5408\u6bd4\u8f83\u65f6&#xff0c;\u6709\u7b26\u53f7\u6570\u4f1a\u88ab\u9690\u5f0f\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7\u6570&#xff0c;\u5bfc\u81f4\u8d1f\u6570&#xff08;\u5982 -1&#xff09;\u53d8\u6210\u8d85\u5927\u6b63\u6570&#xff08;0xFFFFFFFF&#xff09;&#xff0c;\u6bd4\u8f83\u7ed3\u679c\u5b8c\u5168\u53cd\u76f4\u89c9&#xff0c;\u8d1f\u6570\u88ab\u5f53\u4f5c\u5927\u6b63\u6570\u653e\u884c&#xff0c;\u5f15\u53d1\u8d8a\u754c\u8bbf\u95ee\u7b49\u9690\u60a3\u3002\u672c\u6587\u901a\u8fc7\u771f\u5b9e\u7ffb\u8f66\u73b0\u573a\u3001C \u7684\u5bfb\u5e38\u7b97\u672f\u8f6c<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,5078,217,270,219],"topic":[],"class_list":["post-104919","post","type-post","status-publish","format-standard","hentry","category-server","tag-c","tag-freertos","tag-stm32","tag-270","tag-219"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38\uff1a\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7\uff0c\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/104919.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38\uff1a\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7\uff0c\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38&#xff1a;\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7&#xff0c;\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83\u6458\u8981&#xff1a;C \u8bed\u8a00\u4e2d&#xff0c;\u6709\u7b26\u53f7\u6570\u4e0e\u65e0\u7b26\u53f7\u6570\u6df7\u5408\u6bd4\u8f83\u65f6&#xff0c;\u6709\u7b26\u53f7\u6570\u4f1a\u88ab\u9690\u5f0f\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7\u6570&#xff0c;\u5bfc\u81f4\u8d1f\u6570&#xff08;\u5982 -1&#xff09;\u53d8\u6210\u8d85\u5927\u6b63\u6570&#xff08;0xFFFFFFFF&#xff09;&#xff0c;\u6bd4\u8f83\u7ed3\u679c\u5b8c\u5168\u53cd\u76f4\u89c9&#xff0c;\u8d1f\u6570\u88ab\u5f53\u4f5c\u5927\u6b63\u6570\u653e\u884c&#xff0c;\u5f15\u53d1\u8d8a\u754c\u8bbf\u95ee\u7b49\u9690\u60a3\u3002\u672c\u6587\u901a\u8fc7\u771f\u5b9e\u7ffb\u8f66\u73b0\u573a\u3001C \u7684\u5bfb\u5e38\u7b97\u672f\u8f6c\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/104919.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-13T04:41:12+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/104919.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/104919.html\",\"name\":\"\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38\uff1a\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7\uff0c\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-13T04:41:12+00:00\",\"dateModified\":\"2026-09-13T04:41:12+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/104919.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/104919.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/104919.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38\uff1a\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7\uff0c\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38\uff1a\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7\uff0c\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/104919.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38\uff1a\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7\uff0c\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38&#xff1a;\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7&#xff0c;\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83\u6458\u8981&#xff1a;C \u8bed\u8a00\u4e2d&#xff0c;\u6709\u7b26\u53f7\u6570\u4e0e\u65e0\u7b26\u53f7\u6570\u6df7\u5408\u6bd4\u8f83\u65f6&#xff0c;\u6709\u7b26\u53f7\u6570\u4f1a\u88ab\u9690\u5f0f\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7\u6570&#xff0c;\u5bfc\u81f4\u8d1f\u6570&#xff08;\u5982 -1&#xff09;\u53d8\u6210\u8d85\u5927\u6b63\u6570&#xff08;0xFFFFFFFF&#xff09;&#xff0c;\u6bd4\u8f83\u7ed3\u679c\u5b8c\u5168\u53cd\u76f4\u89c9&#xff0c;\u8d1f\u6570\u88ab\u5f53\u4f5c\u5927\u6b63\u6570\u653e\u884c&#xff0c;\u5f15\u53d1\u8d8a\u754c\u8bbf\u95ee\u7b49\u9690\u60a3\u3002\u672c\u6587\u901a\u8fc7\u771f\u5b9e\u7ffb\u8f66\u73b0\u573a\u3001C \u7684\u5bfb\u5e38\u7b97\u672f\u8f6c","og_url":"https:\/\/www.wsisp.com\/helps\/104919.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-13T04:41:12+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/104919.html","url":"https:\/\/www.wsisp.com\/helps\/104919.html","name":"\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38\uff1a\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7\uff0c\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-13T04:41:12+00:00","dateModified":"2026-09-13T04:41:12+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/104919.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/104919.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/104919.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u6709\u7b26\u53f7\u65e0\u7b26\u53f7\u6bd4\u5927\u5c0f\u5f02\u5e38\uff1a\u6df7\u6bd4\u89e6\u53d1\u9690\u5f0f\u8f6c\u65e0\u7b26\u53f7\uff0c\u7edf\u4e00\u7c7b\u578b\u518d\u6bd4\u8f83"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/104919","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=104919"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/104919\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=104919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=104919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=104919"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=104919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}