添加了#define _WINSOCKAPI_
,但构建失败了。
/*
* $PostgreSQL: pgsql/src/include/port/win32/sys/socket.h,v 1.7 2006/10/04 00:30:10 momjian Exp $
*/
#ifndef WIN32_SYS_SOCKET_H
#define WIN32_SYS_SOCKET_H
/*
* Unfortunately, <wingdi.h> of VC++ also defines ERROR.
* To avoid the conflict, we include <windows.h> here and undefine ERROR
* immediately.
*
* Note: Don't include <wingdi.h> directly. It causes compile errors.
*/
#define _WINSOCKAPI_ //added this line but no help
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#undef ERROR
#undef small
/* Restore old ERROR value */
#ifdef PGERROR
#define ERROR PGERROR
#endif
/*
* we can't use the windows gai_strerror{AW} functions because
* they are defined inline in the MS header files. So we'll use our
* own
*/
#undef gai_strerror
#endif /* WIN32_SYS_SOCKET_H */
答案 0 :(得分:1)
您正尝试在绝对不是Windows的平台上编译特定于Windows的头文件。我无法想象你对此的期望;不管它是什么,但它没有。
答案 1 :(得分:0)
尝试使用
#ifndef __APPLE__ ... #endif
然后,检查其他编译错误并包含苹果特定的套接字文件,这些文件也可以在BSD套接字下工作。