This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Configure-time testing for GCC plugins to determine C vs C++? (Was Re: status of GCC & C++)
Hi,
Le 26 mars 2012 à 20:33, Basile Starynkevitch a écrit :
>
> And I still think that GCC 4.7.1 should be able to tell by itself if it was compiled by C
> or by C++.
>
Actually you can already find it for every GCC version you are interested in (4.6.x and 4.7.x), with very little logic, as it was pointed out to you yesterday here http://gcc.gnu.org/ml/gcc/2012-03/msg00381.html and here http://gcc.gnu.org/ml/gcc/2012-03/msg00382.html (the solution with gcc -v as using nm is not a portable solution).
This will work in most case : the targeted GCC you want to build a plugin for can be run on the build machine.
If you need to be able to cross-build a plugin on arch A for a targeted GCC running on host arch B, then you won't be able to invoke gcc -v.
Anyway there is a a solution that works all the time, all you need is being able to grep in a file for a given pattern. Just take a look at the following file : $(gcc -print-file-name=plugin)/include/auto-host.h
You'll find something like this :
/* Define if building with C++. */
#ifndef USED_FOR_TARGET
#define ENABLE_BUILD_WITH_CXX 1
#endif
So that's it, you already got all you need for all version.
Cheers
Romain Geissler