【发布时间】:2015-09-19 01:55:21
【问题描述】:
我做了一些搜索,但我的问题似乎是微不足道的,所以没有人问。
我有一个混合的 c 和 c++ 代码。
在model.h,我有以下声明:
void free_and_null (char **ptr);
在model.cpp,我有函数体:
void free_and_null (char **ptr)
{
if ( *ptr != NULL ) {
free (*ptr);
*ptr = NULL;
}
} /* END free_and_null */
在solve.c 文件中,我有以下内容:
#include "sort.h"
.....
free_and_null ((char **) &x);
当我编译项目时,它有以下链接器错误:
换行) 架构 x86_64 的未定义符号: “_free_and_null”,引用自:
为什么这么简单的程序会出错?我使用 Apple LLVM 6.0 作为编译器。任何输入都受到高度赞赏。
【问题讨论】:
标签: c++ c xcode macos debugging