can any one tell me where can I find the header for __sync_add_and_fetch
built in function
with out header how could we able to compile the code .
Asked
Active
Viewed 1,913 times
2

Bhavith C Acharya
- 345
- 3
- 10
-
Why do you think you need it? Both C and C++ have Standard alternatives (but as they're two languages that forked decades ago, the alternative to use depends on the language you're actually using.) – MSalters Jul 19 '16 at 09:41
1 Answers
6
It is a built-in function, meaning the compiler KNOWS this function, and it doesn't have (to have) a header file.
In clang, it is part of Builtins.def here: https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/Builtins.def#L524
and codegen here: https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CGBuiltin.cpp#L1204
Other compilers will have some similar concepts in declaring "builtin functions".
Of course, not all compilers support atomic builtins, so if you are seeing an error saying "__sync_add_and_fetch is not a function", it may be because the compiler doesn't have that function - it may be called something else in that compiler, or it may simply not exist, depending on what compiler it is.

Mats Petersson
- 126,704
- 14
- 140
- 227