3
意外的行为,我用传统的C代码在我目前的C++项目由包括外部头:混合使用C和C++代码的产量在GCC
extern "C" {
# include "ANN/ANN_4t70P1.h"
# include "ANN/ANN_4t70P2.h"
# include "ANN/ANN_4t70P3.h"
# include "ANN/ANN_4t70P4.h"
}
头文件是这样的:
extern int ANN_4t70P1(float *in, float *out, int init);
static struct {
int NoOfInput; /* Number of Input Units */
int NoOfOutput; /* Number of Output Units */
int(* propFunc)(float *, float*, int);
} ANN_4t70P1REC = {8,3,ANN_4t70P1};
C代码由古老的批处理文件创建,不能使用C++编译器进行编译。尽管如此,这种实现在Windows和Mac OS上运行良好。但是,当我在Linux上使用gcc和g ++编译代码并运行应用程序时,ANN_4t70P1REC返回不正确的值。
链接项目时是否有任何特殊链接器标记遗漏?
谢谢!
ANN_4t70P1REC是一个结构的实例。当你说它“返回不正确的值”时,你是什么意思? –
也许你需要把它全部编译成32位?较新的机器可以安装为64位,因此您可能需要添加'-m32'编译器标记 – epatel
抱歉。当然,我的意思是实例ANN_4t70P1REC中的函数propFunc返回意外的结果。 这些值似乎不是随机值或未分配的内存,但它们与我用XCode或VC++获得的值完全不同。 – bboverflow