Implicit declaration of function 'getaddrinfo' on MinGW

后端 未结 3 450
醉梦人生
醉梦人生 2020-12-17 02:43

I have a C program that uses getaddrinfo(). It works as expected on Linux and Mac OS X.

I\'m in the middle of porting it to Windows.

When I comp

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-17 03:07

    If you have a look at line 297 of ws2tcpip.h, you can see that there's a check of the value of _WIN32_WINNT.

    #if (_WIN32_WINNT >= 0x0501)
    void WSAAPI freeaddrinfo (struct addrinfo*);
    int WSAAPI getaddrinfo (const char*,const char*,const struct addrinfo*,
                    struct addrinfo**);
    int WSAAPI getnameinfo(const struct sockaddr*,socklen_t,char*,DWORD,
                   char*,DWORD,int);
    #else
    /* FIXME: Need WS protocol-independent API helpers.  */
    #endif
    

    Just #define _WIN32_WINNT before your includes.

提交回复
热议问题