我尝试在msys2-mingw上使用Python/C API,所以我安装了
这个包mingw-w64-x86_64-python2,我写main.cpp:

#include <python2.7\Python.h>
int main(){
    return 0;
}

当我输入这个$ g++ main.cpp -o main时,
它给了我这些味精:
In file included from \msys64\mingw64\include/python2.7\Python.h:58:0,
             from main.cpp:1:
\msys64\mingw64\include/python2.7\pyport.h:907:2: 錯誤:#error "LONG_BIT       definition appears wrong for platform (bad gcc/glibc config?)."
 #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
  ^
In file included from \msys64\mingw64\include/python2.7\Python.h:8:0,
             from main.cpp:1:
/usr/include/cygwin/types.h:78:20: 錯誤:一個宣告指定了多個類型
 typedef __uint32_t uid_t;
                ^
/usr/include/cygwin/types.h:78:20: 錯誤:沒有宣告任何東西 [-fpermissive]
/usr/include/cygwin/types.h:84:20: 錯誤:一個宣告指定了多個類型
 typedef __uint32_t gid_t;
                ^
/usr/include/cygwin/types.h:84:20: 錯誤:沒有宣告任何東西 [-fpermissive]
makefile:2: recipe for target 'main' failed
make: *** [main] Error 1

我不知道为什么会这样。这不是linking file的错误(因为我没有链接任何文件。)。我的方法是否错误,或者我包含了错误的文件?

最佳答案

您混合使用GCC:mingw-w64 GCC和msys GCC。对于MSYS2下的mingw-w64 GCC,您必须没有/ usr中的include。查看您的错误消息 /usr/include/cygwin/types.h

10-06 04:58
查看更多