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

I put together a patch for this here:

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:


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.