海湾合作委员会 disables lots of builtins在严格模式下运行时 -std=c...
.
Outside strict ISO C mode (-ansi, -std=c90, -std=c99 or -std=c11), the functions _exit, alloca, bcmp, bzero ... stpcpy, ... may be handled as built-in functions. All these functions have corresponding versions prefixed with _builtin, which may be used even in strict C90 mode.
有什么理由吗?内置函数不符合要求吗?或者这是因为标准说当你调用 memcpy
时它实际上应该调用它并且 i 不能被优化掉?
我觉得如果我使用 -std=gnu*
重新编译它,我的代码肯定会运行得更快,因为它会启用更多 optimizations
GCC normally generates special code to handle certain built-in functions more efficiently; for instance, calls to alloca may become single instructions which adjust the stack directly, and calls to memcpy may become inline copy loops
最佳答案
_exit
、alloca
、bcmp
、bzero
、stpcpy
或该列表中的任何其他函数都是在 C 标准中定义的,因此它们不应由符合标准的 C 编译器定义;这些名称必须可供用户用作他们自己的标识符。
请注意,许多其他内置插件在严格 ISO 模式下仍处于启用状态。例如,memcpy
被“识别为 [a] 内置 [function],除非指定了 -fno-builtin
”
关于optimization - 为什么 GCC 不在严格模式下使用内置函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10676445/