-
Notifications
You must be signed in to change notification settings - Fork 81
Compiler Compatibility
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 clang 3.5 | ok |
Linux clang 4.0 | ok |
Linux clang 6.0 | ok |
Window mingw gcc | ok |
Windows MS CL 2017 | ko |
Windows MS CL 2019 | ko |
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.
- First 2019 version of Visual C++ fixes it providing the options /experimental:preprocessor (to preprocess correctly the code) and /Zc:__cplusplus (to detect the correct version of C++) are used to build your program. However, there is still an internal compiler error that is triggered when using snapshots. Everything else worked fine and it provided a lot of warnings about wrong number of arguments for macros (this seems too like a compiler fault). However last patchlevel version of the compiler refuses to compile anymore due to broken preprocessing once again.
- clang may produce a lot of warnings about unused 'static inline' functions. This behavior is considered as a bug by clang maintainers.
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.
M*Lib shall be compatible with C++ compiler.