Skip to content

Compiler Compatibility

PpHd edited this page Oct 25, 2020 · 37 revisions

Compiler support

Any C99 compliant compiler should work. Here is the result of the test suite against different systems:

compiler support
Linux gcc 4.9  ok
Linux gcc 6.1 ok
Linux gcc 7.1 ok
Linux gcc 8.1 ok
Linux gcc 9.1 ok
Linux gcc 10.1 ok
Linux clang 3.5 ok
Linux clang 4.0 ok
Linux clang 6.0 ok
Linux clang 7.0 ok
Linux clang 8.0 ok
Linux clang 9.0 ok
MacOS clang 10.0 ok
Window mingw gcc ok
Window msys gcc ok
Windows MS CL 2017 ko
Windows MS CL 2019 ok
Window clang 10.0 ok
Linux Intel ICC 17 ok
Linux-tcc GIT ok

NOTES:

  • Variadic macros are not properly supported by Microsoft Visual C++ compiler 2017, resulting in huge incompatibility with M*LIB. See here or here.
  • Microsoft Visual C++ 2019 version 16.6 fixes it by providing the options /Zc:preprocessor (to preprocess correctly the code) and /Zc:__cplusplus (to detect the correct version of C++) are used to build your program.

stdatomic

stdatomic.h is a new header introduced with the version C11 of the C standard. However it is not supported by the C++ standard (even in 2017) - for whatever reason -.

In general, the same compiler provides both the C variant and the C++ variant, so you could expect that even in C++ mode, you should be able to use this header. Well, no. See here. This is due to the C++ backend not supporting the _Atomic keyword! There is some alternative to do: using the C++ header "atomic" and uses the atomic_* types... which pretty much what they had to specify in the C++ standard!

M*lib has a new header "m-atomic.h" which does this, and as such is compatible with both C and C++. It also provides its own implementation of atomics based on mutex in cases no atomic header is available. This implementation is slow but it should disappear as soon as the compilers provide proper support for atomics operation.

clang supports this keyword in C++ mode, so there is no problem with it using stdatomic.

I am sad by this state of growing incompatibility between C & C++.

NOTE: GCC 4.9 STL has a bug in its atomic implementation which makes atomic_int incompatible with atomic_load. This is fixed in latter versions.

C++ compatibility

M*Lib shall be compatible with C++ compiler provided they supported at least C++11

Clone this wiki locally