Bhavith C Acharya
Bhavith C Acharya

Reputation: 355

where can i find the header of __sync_add_and_fetch

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 .

Upvotes: 2

Views: 2395

Answers (1)

Mats Petersson
Mats Petersson

Reputation: 129524

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.

Upvotes: 6

Related Questions