[Bug c++/53673] Add magic weak symbol to indicate C++ standard setting (C++03, C++11 etc) to help debug ABI problems

pluto at agmk dot net gcc-bugzilla@gcc.gnu.org
Thu Jun 14 20:06:00 GMT 2012


Pawel Sikora <pluto at agmk dot net> changed:

           What    |Removed                     |Added
                 CC|                            |pluto at agmk dot net

--- Comment #2 from Pawel Sikora <pluto at agmk dot net> 2012-06-14 20:06:15 UTC ---
(In reply to comment #0)
> Can we have a magic weak symbol output by G++ into compilands saying what -std
> setting was used? For example:
> No -std outputs __gplusplus_std_cpluscplus98
> -std=c++03 outputs __gplusplus_std_cplusplus03
> -std=gnu++03 outputs __gplusplus_std_gnu03
> -std=c++11 outputs __gplusplus_std_cplusplus11
> -std=gnu++11 outputs __gplusplus_std_gnu11
> ... and so on ...
> Why? Because right now it's too easy to accidentally link object files compiled
> with 98 with those compiled with 11 and not then know why things spontaneously
> fail:
> http://gcc.gnu.org/ml/gcc/2012-06/msg00201.html
> http://gcc.gnu.org/wiki/Cxx11AbiCompatibility
> If __gplusplus_std_cpluscplus98 and __gplusplus_std_cplusplus11 both turn up in
> a shared object or executable, then we know we have combined 98 and 11 built
> code. Indeed, a future ld could warn if this happens.
> Niall

you can use -frecord-gcc-switches to detect mixed objects in linked library.

More information about the Gcc-bugs mailing list