3 ms·
Clang and GCC will generally compile standard C/C++ code just fine, but they add their own extensions to the language. I'd bet a lot of C or C++ projects assume
by mort96 8y ago
Clang and GCC will generally compile standard C/C++ code just fine, but they add their own extensions to the language. I'd bet a lot of C or C++ projects assume `void` has a size of 1 in pointer arithmetic, for example. Try compiling some projects with -Wpedantic.
Now, Clang tries to implement the various GNU extensions, but there are some relatively significant differences. For example, GCC has no problem with a (conditional) goto to a label pointer even if you never took the address of a label anywhere in that function, while Clang treats that as an error, which can be a problem when using macros. Clang also treats _Pragma in macro arguments as you'd expect, while GCC puts all the pragmas before the rest of the code in the macro argument.
Those are just differences I persinally have struggled with, I'm sure there are more.
- exDM69 8y agoWhile there are differences between Clang and GCC language extensions, most of them are compatible or at least can be worked around with some relatively trivial hacks. Compare this with trying to support MSVC, which supports none of the extensions and has a poor track record of getting even the standard stuff straight (especially in the C, not C++, compiler). By dropping MSVC, you gain a lot of useful language extensions that work with Clang and GCC. For example you get portable SIMD, atomic operations and cache prefetching and a lot of other __builtin features which are unambiguously useful. The alternative is to support MSVC but then have to maintain some kind of middleware layer to work around compiler incompatibilities. Since the platforms supported by MSVC are already covered by other compilers, you don't gain a lot.