• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 132  文章 - 51  trackbacks - 0
            <2010年9月>
            2930311234
            567891011
            12131415161718
            19202122232425
            262728293012
            3456789

            常用鏈接

            留言簿(7)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            cocos2d-x

            OGRE

            OPenGL

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            今天編譯工程的時候遇到了這個問題,網上搜了下,掃噶,備忘一下
            問題描述:在 VC 6.0中使用socket相關的函數時沒有什么問題,可是到了.net下就有以下類似的錯誤,
            [C++ Error] winsock2.h(109): E2238 Multiple declaration for 'fd_set'
            [C++ Error] winsock.h(54): E2344 Earlier declaration of 'fd_set'
            [C++ Error] winsock2.h(112): E2146 Need an identifier to declare
            [C++ Warning] winsock2.h(144): W8017 Redefinition of 'FD_SET' is not identical
            [C++ Error] winsock2.h(153): E2238 Multiple declaration for 'timeval'
            [C++ Error] winsock.h(97): E2344 Earlier declaration of 'timeval'
            [C++ Error] winsock2.h(209): E2238 Multiple declaration for 'hostent'
            [C++ Error] winsock.h(153): E2344 Earlier declaration of 'hostent'
            [C++ Error] winsock2.h(222): E2238 Multiple declaration for 'netent'
            [C++ Error] winsock.h(166): E2344 Earlier declaration of 'netent'
            [C++ Error] winsock2.h(229): E2238 Multiple declaration for 'servent'
            [C++ Error] winsock.h(173): E2344 Earlier declaration of 'servent'
            [C++ Error] winsock2.h(241): E2238 Multiple declaration for 'protoent'
            [C++ Error] winsock.h(185): E2344 Earlier declaration of 'protoent'
            [C++ Error] winsock2.h(327): E2238 Multiple declaration for 'in_addr'
            [C++ Error] winsock.h(269): E2344 Earlier declaration of 'in_addr'
            [C++ Error] winsock2.h(385): E2238 Multiple declaration for 'sockaddr_in'
            [C++ Error] winsock.h(319): E2344 Earlier declaration of 'sockaddr_in'
            [C++ Error] winsock2.h(395): E2238 Multiple declaration for 'WSAData'
            [C++ Error] winsock.h(329): E2344 Earlier declaration of 'WSAData'
            [C++ Error] winsock2.h(411): E2146 Need an identifier to declare
            [C++ Warning] winsock2.h(455): W8017 Redefinition of 'SO_DONTLINGER' is not identical
            [C++ Warning] winsock2.h(512): W8017 Redefinition of 'AF_IPX' is not identical
            [C++ Warning] winsock2.h(540): W8017 Redefinition of 'AF_MAX' is not identical
            [C++ Error] winsock2.h(546): E2238 Multiple declaration for 'sockaddr'
            [C++ Error] winsock.h(492): E2344 Earlier declaration of 'sockaddr'
            [C++ Error] winsock2.h(586): E2238 Multiple declaration for 'sockproto'
            [C++ Error] winsock.h(501): E2344 Earlier declaration of 'sockproto'
            [C++ Error] winsock2.h(625): E2238 Multiple declaration for 'linger'
            [C++ Error] winsock2.h(625): E2228 Too many error or warning messages

            Solution:

            This problem arises because windows.h (at least, that version of it) includes not winsock2.h but winsock.h; sadly when Microsoft wrote winsock2.h they chose neither to change windows.h to include winsock2.h, which replaces winsock.h, nor to include windows.h from winsock2.h and then add the definitions for the new Winsock 2 API methods & structures (this might seem reasonable since Winsock 2 does, strictly speaking, replace Winsock 1, but since the API must be fully backwards-compatible the distinction is somewhat meaningless and there's no real benefit to making winsock2.h standalone).

            The fix is thankfully simple: always "#include <winsock2.h>" before windows.h.

            However, you must remember that if windows.h has been included by (for example) a higher-level header file that is subsequently including your header file, it's too late - so you must make sure that the higher-level header files respect this convention also.

            It is however rarely necessary to modify the header files of libraries or other code modules you are using just because you include their header files, and their header files include windows.h - you can just include winsock2.h before you include the library's header files.


            在包含jrtplib有時候我也遇到這個問題,解決方法與之相同。一句話,在#include<windows.h>之前 #include <winsock2.h> 問題就可以解決。

            問題描述]
               在包含了<windows.h>以及<winsock2.h>的工程中,編譯有時會出現如
            下錯誤:

                 error C2011: 'fd_set' : 'struct' type redefinition
                 error C2011: 'timeval' : 'struct' type redefinition
                                 ....
                 error C2375: 'accept' : redefinition; different linkage
            [原因分析]
               主要原因是因為<windows.h>中包含了<winsock.h>頭文件,由于其版
            本的不同,導致出
            現上述的錯誤。<windows.h>中相關代碼如下:
                           #ifndef WIN32_LEAN_AND_MEAN
                           #include <cderr.h>
                           #include <dde.h>
                           #include <ddeml.h>
                           ........
                            #ifndef _MAC
                           #include <winperf.h>
                           #include <winsock.h>
                           #endif
                            .......

                           #include <commdlg.h>
                           #endif
                           #endif
            [解決方案]
                由以上代碼可以看出如果在沒有定義WIN32_LEAN_AND_MEAN宏
            的大前
            提下windows.h有可能包含winsock.h 頭文件,因此我們得出一個很簡單
            的解決方
            法就是在包含<windows.h>之前定義WIN32_LEAN_AND_MEAN宏,如
            下所示:
            #define WIN32_LEAN_AND_MEAN
            #include <windows.h>

             原文地址 http://blog.sina.com.cn/s/blog_4906d564010094p8.html
            posted on 2010-10-23 14:01 風輕云淡 閱讀(969) 評論(0)  編輯 收藏 引用 所屬分類: C++
            国产亚洲精品久久久久秋霞 | 久久久久久国产精品美女 | 日本一区精品久久久久影院| 久久国产成人午夜AV影院| 国产亚洲精品久久久久秋霞| 国产精品久久久久久久久鸭 | 久久久无码人妻精品无码| 精品乱码久久久久久夜夜嗨| 人妻无码精品久久亚瑟影视| 久久国产高清一区二区三区| 97精品依人久久久大香线蕉97| 国内精品久久国产大陆| 俺来也俺去啦久久综合网| 久久久久人妻精品一区二区三区| 99久久国产综合精品五月天喷水| 久久久久一区二区三区| 亚洲中文久久精品无码ww16| 亚洲成人精品久久| 欧美熟妇另类久久久久久不卡| 一本色道久久99一综合| 久久久久一级精品亚洲国产成人综合AV区| 国产精品久久免费| 97精品依人久久久大香线蕉97| 久久亚洲中文字幕精品一区四| 精品久久香蕉国产线看观看亚洲| 亚洲精品乱码久久久久久中文字幕| 国内精品久久久久久久久电影网| 久久精品?ⅴ无码中文字幕| 国产精品久久久久影院嫩草| 欧美大香线蕉线伊人久久| 久久亚洲AV成人无码| 亚洲国产日韩欧美久久| 欧美亚洲色综久久精品国产| 久久青青草视频| 国产精品对白刺激久久久| 亚洲中文精品久久久久久不卡| 久久久久久久久66精品片| 久久毛片一区二区| 久久久久久国产精品美女| 久久狠狠高潮亚洲精品| 久久久久久亚洲Av无码精品专口 |