c - 为什么 gcc 不提示缺少符号?

标签 c gcc macros compiler-errors

我在 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/

相关文章:

c - Makefile FFLAGS 描述

c - char* 的合法使用

c - 一直运行直到用户进入q简单程序流程

c++ - Mac 上的 OpenMP 不再工作

c++ - 不能在带有 try/catch 的构造函数初始化列表中使用统一初始化

c++ - double 或浮点比较

c - strcpy(m+1,m) 的不可预测行为

用于创建查找表的 C 预处理器宏

macros - 迭代创建局部变量?

macros - Lisp 宏的用途示例