我在 c 文件中定义了以下内容:
#ifdef __clang__
// clang definition here
#elif defined _GNULINUX
#define _ALIGNED_FREE(pMempointer) _free((pMempointer))
#elif defined _MSC_VER
// VS definition here
#else
// default definition
#endif
void * pMemory = 0L;
if(pMemory) {
_ALIGNED_FREE(pMemory);
}
gcc 标志是:
-Wall -Wno-long-long -fexpense-optimizations -fomit-frame-pointer -funroll-loops -pipe -fexceptions -Wpointer-arith -Wcast-align -Wsign-compare -pedantic -mmmx -msse
>
使用 gcc 版本 4.8.2 成功编译(在 Ubuntu 14.04 计算机中)后,程序在运行时退出,并显示 undefined symbol :_free
显然符号_free
是未知的,但是为什么gcc不提示这个呢?我希望它会像 VS 链接器那样在链接时抛出错误。
最佳答案
free
在 Linux 中和 C 标准中都没有前导下划线。
关于c - 为什么 gcc 不提示缺少符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28982414/