[cfe-dev] [RFC] Adding -fgnuc-version=x.y.z to let users set __GNUC__ or disable all GCC macros

Reid Kleckner via cfe-dev cfe-dev at lists.llvm.org
Thu Sep 26 14:12:12 PDT 2019


I put together a patch for this here:
https://reviews.llvm.org/D68055
By default clang will continue to claim to be GCC version 4.2.1, so there
is no change if you don't pass the flag.

I originally came at this from the angle of wanting a language option that
affirmatively says "yes, enable GCC-compatible extensions". Today a lot of
GCC-isms are controlled by !-fms-compatibility, which is not so good if you
ever try turning off MSVC compatibility. I propose that the presence of the
new flag should control the various __GXX* macros we set, as is done in the
patch.

Separately, folks periodically have issues with clang's advertised GCC
version:
http://lists.llvm.org/pipermail/cfe-dev/2019-July/062890.html
https://llvm.org/PR42817

This gives users an easier way to control that aside from -U__GNUC__
-D__GNUC__=5 etc. It also gives us a way of easily testing different
__GNUC__ values without rebuilding clang. Maybe one day we could even stop
defining __GNUC__ by default. =P

There's no major functionality change here, but I figured I should raise
awareness about this flag and maybe add it to our release notes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190926/1cc75b5a/attachment.html>


More information about the cfe-dev mailing list