【发布时间】:2011-06-10 17:08:30
【问题描述】:
我正在使用 swig 生成一个 python C++ 接口,这样我就可以在 python 中编写脚本来调用我的 c++ 函数。我已经做到了:
swig -c++ python filename.i
gcc -c filename.cpp filename_wrap.cxx -shared -Ic:\includepath
包含路径是我的python27的包含目录。
在尝试使用 gcc 编译时,我收到一大堆错误,说明我的许多函数被声明为 extern 而现在是静态的。在原始的 cpp 文件中,我将我的一些函数声明为静态的。我从来没有将任何东西声明为外部。这可能是什么原因造成的?
这是我的接口文件
/* Interface */
%module ReadWrite
%{
#include "ReadWrite.h"
%}
%include "ReadWrite.h"
头文件的 sn-p(名称已更改)如下所示(没有任何东西被声明为 extern)
static bool myfunc1(void);
static bool myfunc2 (type1 *Entry, type2 *Block, type2 *Data);
static bool myfunc3 (type2 *Data, type3 **Records, type2 **Header);
type4 myfunc4 (void) ;
当我执行 gcc -c ReadWrite.cpp ReadWrite_wrap.cxx -shared -Ic:\includepath 时,我会收到来自 gcc: 之类的错误:
ReadWrite.cpp:682:79: error: 'bool myfunc3 (type2 *Data, type3 **Records, type2 **Header)' 被声明为 'extern' 和后来的 'static'
【问题讨论】:
-
如果没有一些有问题的代码的 sn-ps,我认为不可能做出合理的猜测。
-
将代码添加到主帖。片刻。
-
是的,但甚至可能是确切的编译器错误?