'wmemcpy' undefined; assuming extern returning int

VC6 的问题 对标准C支持不完美 C代码竟然用CPP实现 源代码如下
<div class="language-c highlighter-rouge">
<pre class="highlight"><span class="cp">#ifdef __cplusplus
</span><span class="kr">inline</span> <span class="kt">int</span> <span class="nf">fwide</span><span class="p">(</span><span class="kt">FILE</span> <span class="o">*</span><span class="p">,</span> <span class="kt">int</span> <span class="n">_M</span><span class="p">)</span>

    <span class="p">{</span><span class="k">return</span> <span class="p">(</span><span class="n">_M</span><span class="p">);</span> <span class="p">}</span>

<span class="kr">inline</span> <span class="kt">int</span> <span class="nf">mbsinit</span><span class="p">(</span><span class="k">const</span> <span class="kt">mbstate_t</span> <span class="o">*</span><span class="p">)</span>

    <span class="p">{</span><span class="k">return</span> <span class="p">(</span><span class="mi">1</span><span class="p">);</span> <span class="p">}</span>

<span class="kr">inline</span> <span class="k">const</span> <span class="kt">wchar_t</span> <span class="o"></span><span class="nf">wmemchr</span><span class="p">(</span><span class="k">const</span> <span class="kt">wchar_t</span> <span class="o"></span><span class="n">_S</span><span class="p">,</span> <span class="kt">wchar_t</span> <span class="n">_C</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">_N</span><span class="p">)</span>

    <span class="p">{</span><span class="k">for</span> <span class="p">(;</span> <span class="mi">0</span> <span class="o"><</span> <span class="n">_N</span><span class="p">;</span> <span class="o">++</span><span class="n">_S</span><span class="p">,</span> <span class="o">--</span><span class="n">_N</span><span class="p">)</span>
            <span class="k">if</span> <span class="p">(</span><span class="o">*</span><span class="n">_S</span> <span class="o">==</span> <span class="n">_C</span><span class="p">)</span>
                    <span class="k">return</span> <span class="p">(</span><span class="n">_S</span><span class="p">);</span>
    <span class="k">return</span> <span class="p">(</span><span class="mi">0</span><span class="p">);</span> <span class="p">}</span>

<span class="kr">inline</span> <span class="kt">int</span> <span class="nf">wmemcmp</span><span class="p">(</span><span class="k">const</span> <span class="kt">wchar_t</span> <span class="o"></span><span class="n">_S1</span><span class="p">,</span> <span class="k">const</span> <span class="kt">wchar_t</span> <span class="o"></span><span class="n">_S2</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">_N</span><span class="p">)</span>

    <span class="p">{</span><span class="k">for</span> <span class="p">(;</span> <span class="mi">0</span> <span class="o"><</span> <span class="n">_N</span><span class="p">;</span> <span class="o">++</span><span class="n">_S1</span><span class="p">,</span> <span class="o">++</span><span class="n">_S2</span><span class="p">,</span> <span class="o">--</span><span class="n">_N</span><span class="p">)</span>
            <span class="k">if</span> <span class="p">(</span><span class="o">*</span><span class="n">_S1</span> <span class="o">!=</span> <span class="o">*</span><span class="n">_S2</span><span class="p">)</span>
                    <span class="k">return</span> <span class="p">(</span><span class="o">*</span><span class="n">_S1</span> <span class="o"><</span> <span class="o">*</span><span class="n">_S2</span> <span class="o">?</span> <span class="o">-</span><span class="mi">1</span> <span class="o">:</span> <span class="o">+</span><span class="mi">1</span><span class="p">);</span>
    <span class="k">return</span> <span class="p">(</span><span class="mi">0</span><span class="p">);</span> <span class="p">}</span>

<span class="kr">inline</span> <span class="kt">wchar_t</span> <span class="o"></span><span class="nf">wmemcpy</span><span class="p">(</span><span class="kt">wchar_t</span> <span class="o"></span><span class="n">_S1</span><span class="p">,</span> <span class="k">const</span> <span class="kt">wchar_t</span> <span class="o">*</span><span class="n">_S2</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">_N</span><span class="p">)</span>

    <span class="p">{</span><span class="kt">wchar_t</span> <span class="o">*</span><span class="n">_Su1</span> <span class="o">=</span> <span class="n">_S1</span><span class="p">;</span>
    <span class="k">for</span> <span class="p">(;</span> <span class="mi">0</span> <span class="o"><</span> <span class="n">_N</span><span class="p">;</span> <span class="o">++</span><span class="n">_Su1</span><span class="p">,</span> <span class="o">++</span><span class="n">_S2</span><span class="p">,</span> <span class="o">--</span><span class="n">_N</span><span class="p">)</span>
            <span class="o">*</span><span class="n">_Su1</span> <span class="o">=</span> <span class="o">*</span><span class="n">_S2</span><span class="p">;</span>
    <span class="k">return</span> <span class="p">(</span><span class="n">_S1</span><span class="p">);</span> <span class="p">}</span>

<span class="kr">inline</span> <span class="kt">wchar_t</span> <span class="o"></span><span class="nf">wmemmove</span><span class="p">(</span><span class="kt">wchar_t</span> <span class="o"></span><span class="n">_S1</span><span class="p">,</span> <span class="k">const</span> <span class="kt">wchar_t</span> <span class="o">*</span><span class="n">_S2</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">_N</span><span class="p">)</span>

    <span class="p">{</span><span class="kt">wchar_t</span> <span class="o">*</span><span class="n">_Su1</span> <span class="o">=</span> <span class="n">_S1</span><span class="p">;</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">_S2</span> <span class="o"><</span> <span class="n">_Su1</span> <span class="o">&&</span> <span class="n">_Su1</span> <span class="o"><</span> <span class="n">_S2</span> <span class="o">+</span> <span class="n">_N</span><span class="p">)</span>
            <span class="k">for</span> <span class="p">(</span><span class="n">_Su1</span> <span class="o">+=</span> <span class="n">_N</span><span class="p">,</span> <span class="n">_S2</span> <span class="o">+=</span> <span class="n">_N</span><span class="p">;</span> <span class="mi">0</span> <span class="o"><</span> <span class="n">_N</span><span class="p">;</span> <span class="o">--</span><span class="n">_N</span><span class="p">)</span>
                    <span class="o">*--</span><span class="n">_Su1</span> <span class="o">=</span> <span class="o">*--</span><span class="n">_S2</span><span class="p">;</span>
    <span class="k">else</span>
            <span class="k">for</span> <span class="p">(;</span> <span class="mi">0</span> <span class="o"><</span> <span class="n">_N</span><span class="p">;</span> <span class="o">--</span><span class="n">_N</span><span class="p">)</span>
                    <span class="o">*</span><span class="n">_Su1</span><span class="o">++</span> <span class="o">=</span> <span class="o">*</span><span class="n">_S2</span><span class="o">++</span><span class="p">;</span>
    <span class="k">return</span> <span class="p">(</span><span class="n">_S1</span><span class="p">);</span> <span class="p">}</span>

<span class="kr">inline</span> <span class="kt">wchar_t</span> <span class="o"></span><span class="nf">wmemset</span><span class="p">(</span><span class="kt">wchar_t</span> <span class="o"></span><span class="n">_S</span><span class="p">,</span> <span class="kt">wchar_t</span> <span class="n">_C</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">_N</span><span class="p">)</span>

    <span class="p">{</span><span class="kt">wchar_t</span> <span class="o">*</span><span class="n">_Su</span> <span class="o">=</span> <span class="n">_S</span><span class="p">;</span>
    <span class="k">for</span> <span class="p">(;</span> <span class="mi">0</span> <span class="o"><</span> <span class="n">_N</span><span class="p">;</span> <span class="o">++</span><span class="n">_Su</span><span class="p">,</span> <span class="o">--</span><span class="n">_N</span><span class="p">)</span>
            <span class="o">*</span><span class="n">_Su</span> <span class="o">=</span> <span class="n">_C</span><span class="p">;</span>
    <span class="k">return</span> <span class="p">(</span><span class="n">_S</span><span class="p">);</span> <span class="p">}</span>

<span class="p">}</span> <span class="cm">/ end of extern "C" /</span></pre>
</div>

赞(0) 打赏
取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

    暂无评论...