簡體   English   中英

cygwin g ++使用Python.h編譯(__BSD_VISIBLE的重復定義)

[英]cygwin g++ compiling with Python.h (duplicated definition of __BSD_VISIBLE)

我在使用最新的cygwin g ++-5.4.0和python3.4時遇到此問題。 以下簡單代碼暴露了此問題:

#include <string>
#include <Python.h>
#include <vector>
#include <map>
//#include <string>
#include <iostream>

int main(int argc, char ** argv)
{
    return 0;
}

用“ g ++ -g -O2 -std = c ++ 11 test.c -o test python3-config --includes ”編譯后,出現以下錯誤:

In file included from /usr/include/python3.4m/Python.h:8:0,
                 from test.c:2:
/usr/include/python3.4m/pyconfig.h:1440:0: warning: "__BSD_VISIBLE" redefined
 #define __BSD_VISIBLE 1
 ^
In file included from /usr/include/sys/config.h:5:0,
                 from /usr/include/_ansi.h:16,
                 from /usr/include/wchar.h:4,
                 from /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/cwchar:44,
                 from /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/bits/postypes.h:40,
                 from /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/bits/char_traits.h:40,
                 from /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/string:40,
                 from test.c:1:
/usr/include/sys/features.h:250:0: note: this is the location of the previous definition
 #define __BSD_VISIBLE  0
 ^
In file included from /usr/include/python3.4m/pyport.h:335:0,
                 from /usr/include/python3.4m/Python.h:50,
                 from test.c:2:
/usr/include/sys/time.h:104:34: error: 'u_int' has not been declared bintime_mul(struct bintime *_bt, u_int _x)

一件棘手的事情是,如果我在“ Python.h”之后加入。 編譯通過。 我在Linux / Mac OS上看不到此問題。

我認為這不是有效的解決方案。 由於使用了更復雜的代碼,因此我在程序的最開始就遇到了默認的段(在進入主函數之前)。

修改文件/usr/include/python3.4m/pyconfig.h ,替換為

#define __BSD_VISIBLE 1

#define __BSD_VISIBLE 0

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM