让我们假设下面的代码:
#include <stdio.h>
#include <math.h>
int abs(int x){
return x*2;
}
int main(){
printf("%d\n",abs(-2));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我编译并执行它时,我注意到正在使用math.h的abs函数。实际上,即使我删除#include <math.h>,也会发生这种情况。但我不明白这里发生了什么。
abs未在math.honly中声明stdlib.h。-fno-builtin标志,程序将按照您的方式运行。https://godbolt.org/z/v9xM3jbbj