我在哪里可以找到__sync_add_and_fetch的标头

时间:2016-07-19 05:48:49

标签: c++ c unix systems-programming

任何人都可以告诉我在哪里可以找到__sync_add_and_fetch内置函数的标题
如果我们能够编译代码。

1 个答案:

答案 0 :(得分:4)

它是一个内置函数,意味着编译器知道这个函数,它没有(有)头文件。

在clang中,它是Builtins.def的一部分: https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/Builtins.def#L524

和codegen在这里: https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGBuiltin.cpp#L1204

其他编译器在声明“内置函数”时会有一些类似的概念。

当然,并非所有编译器都支持原子内置,所以如果你看到一个错误“__sync_add_and_fetch不是一个函数”,那可能是因为编译器没有那个函数 - 它可能被称为其他内容编译器,或者可能根本不存在,具体取决于它是什么编译器。