使用 Visual Studio 编译 libcurl(bool undefined)

Compiling libcurl with Visual Studio (bool undefined)

本文关键字:bool undefined libcurl Visual Studio 编译 使用      更新时间:2023-10-16

我想在Visual Studio项目中编译源代码的curl。

我收到此错误(以及更多):

curlsrctool_sdecls.h(67): error C2061: Syntax Error: Identifier'bool' (......frameworklibscurlsrctool_cb_dbg.c)
curlsrctool_sdecls.h(68): error C2061: Syntax Error: Identifier'bool'is_cd_filename' (......frameworklibscurlsrctool_cb_dbg.c)
curlsrctool_sdecls.h(68): error C2059: Syntax Error: ';' (......frameworklibscurlsrctool_cb_dbg.c)

此文件的来源是:

65:  struct OutStruct {
66:      char *filename;
67:      bool alloc_filename;
68:      bool is_cd_filename;
69:      bool s_isreg;
...

由于某种原因,似乎没有定义bool。我尝试定义HAVE_BOOL_T但没有任何变化。

知道吗?谢谢

为了解决这个问题,我添加了以下内容curl_config.h

//for undefined bool error
#if _MSC_VER > 1700
    #include <stdbool.h>
#else
    #ifndef bool
        typedef int bool;
        #define false 0
        #define true 1
    #endif
#endif
//for warning C4005: 'POLLIN' : macro redefinition error
#define _WIN32_WINNT 0x0501