【发布时间】:2011-03-05 04:26:27
【问题描述】:
我有一段从 C++ 函数中使用的 C 代码。在我的 C++ 文件的顶部有一行:#include "prediction.h"
在prediction.h 我有这个:
#ifndef prediction
#define prediction
#include "structs.h"
typedef struct {
double estimation;
double variance;
} response;
response runPrediction(int obs, location* positions, double* observations,
int targets, location* targetPositions);
#endif
我也有prediction.c,其中有:
#include "prediction.h"
response runPrediction(int obs, location* positions, double* observations,
int targets, location* targetPositions) {
// code here
}
现在,在我的 C++ 文件(正如我所说的包含 prediction.h)中,我调用了该函数,然后编译(通过 Xcode)我得到了这个错误:
“runPrediction(int, location*, double*, int, location*)”,引用自:
mainFrame::respondTo(char*, int) in mainFrame.o
ld:未找到符号
collect2: ld 返回 1 个退出状态
prediction.c 被标记为针对当前目标进行编译。我对未编译的其他 .cpp 文件没有任何问题。这里有什么想法吗?
【问题讨论】:
-
通过在代码前面加上 4 个空格来格式化代码,101010 按钮将为您完成。您可以通过用反引号包围代码来执行内联代码(cmets 中的唯一方法),因此 `some code` 变为
some code。我用反斜杠避开了以前的反引号。 -
啊,我明白了,我想我尝试同时使用块引号和 4 个空格;难怪它不起作用。 :)
标签: c++ c xcode compiler-construction