简体   繁体   中英

Does GCC atomic buitlins work with std=C99?

I am using this built-in atomic methods link It is mentioned that:

The following built-in functions approximately match the requirements for the C++11 memory model.

However I have tried compiling these methods with std=C99 and std=C89 . The program compiles and I get the right results. Is there something I am missing here ? Does C99 and C89 have a memory model as well ?

It is a compiler extension and therefore it is allowed to provide functionality outside of the what the standard allows but that page does not make it obvious that is the can be used in C.

Fortunately, gcc does have good online documents and if we check out for example the 4.9 series document on C extensions the __atomic Builtins points to the same page.

So that would indicate that it is valid to use in C and it will stick the requirements as laid out in the documentation and so it will work in the C99 as it does in C++. Usually if there is a difference between how a feature/extension is implemented between C and C++ the documents will note this, for example compound literals have significant differences.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM