Hello All, The fie plugin-version.h is now generated by gcc/configure.ac. It contains version information (about the GCC supposed to load the plugin compiled with it) as constant strings.
But I think it will also help some plugin developers if that file (which is packaged in gcc-4.6-plugin-dev on Debian/Sid, i.e. as the plugin development package) contained preprocessor macros defining the same versions. So this patch generates constant macros like #define GCCPLUGIN_VERSION_STRING "4.7.0" #define GCCPLUGIN_VERSION_MAJOR 4 #define GCCPLUGIN_VERSION_MINOR 7 #define GCCPLUGIN_VERSION_MICRO 0 #define GCCPLUGIN_VERSION (GCCPLUGIN_VERSION_MAJOR*1000 + GCCPLUGIN_VERSION_MINOR) #define GCCPLUGIN_DEVPHASE "experimental" #define GCCPLUGIN_REVISION "[trunk revision 175910]" in the plugin-version.h file. I belive it can help to make plugin code more robust. A serious plugin developper could then add in his plugin code something like #if GCCPLUGIN_VERSION != 4007 #error this plugin can be built only for GCC 4.7 #endif and with such a feature the plugin won't even compile if, for one reason or another, the wrong gcc has been considered i.e. passed with -I$(gcc -print-file-name=plugin) This brings some help to the careful plugin coder, and don't harm GCC itself. For GCC trunk or branches we have the BUILDING_GCC_VERSION macro, but it does not appear in the headers insdtalled by gcc-4.6-plugin-dev package. Plugins can currently only check for version compatibility at plugin dlopen time, not at plugin build time! I am attaching the diff file gccplugin_rev_configure_r175910.diff against trunk 175910 ### gcc/ChangeLog entry #### 2011-07-06 Basile Starynkevitch <bas...@starynkevitch.net> * configure.ac (plugin-version.h): Generate GCCPLUGIN_VERSION_STRING, GCCPLUGIN_VERSION_MAJOR, GCCPLUGIN_VERSION_MINOR, GCCPLUGIN_VERSION_MICRO, GCCPLUGIN_VERSION_NUMBER, GCCPLUGIN_DEVPHASE, GCCPLUGIN_REVISION macros. * configure: Regenerate. ############################# Ok for trunk, with what changes? Regards. PS. While this would help the MELT plugin, I am very sure it could help other plugins coders! -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mines, sont seulement les miennes} ***
Index: gcc/configure =================================================================== --- gcc/configure (revision 175910) +++ gcc/configure (working copy) @@ -11072,6 +11072,14 @@ cat > plugin-version.h <<EOF #include "configargs.h" +#define GCCPLUGIN_VERSION_STRING "$gcc_BASEVER" +#define GCCPLUGIN_VERSION_MAJOR `cut -d. -f1 $srcdir/BASE-VER` +#define GCCPLUGIN_VERSION_MINOR `cut -d. -f2 $srcdir/BASE-VER` +#define GCCPLUGIN_VERSION_MICRO `cut -d. -f3 $srcdir/BASE-VER` +#define GCCPLUGIN_VERSION (GCCPLUGIN_VERSION_MAJOR*1000 + GCCPLUGIN_VERSION_MINOR) +#define GCCPLUGIN_DEVPHASE "$gcc_DEVPHASE" +#define GCCPLUGIN_REVISION "$gcc_REVISION" + static char basever[] = "$gcc_BASEVER"; static char datestamp[] = "$gcc_DATESTAMP"; static char devphase[] = "$gcc_DEVPHASE"; @@ -17623,7 +17631,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17626 "configure" +#line 17634 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -17729,7 +17737,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17732 "configure" +#line 17740 "configure" #include "confdefs.h" #if HAVE_DLFCN_H Index: gcc/configure.ac =================================================================== --- gcc/configure.ac (revision 175910) +++ gcc/configure.ac (working copy) @@ -1511,6 +1511,14 @@ cat > plugin-version.h <<EOF #include "configargs.h" +#define GCCPLUGIN_VERSION_STRING "$gcc_BASEVER" +#define GCCPLUGIN_VERSION_MAJOR `cut -d. -f1 $srcdir/BASE-VER` +#define GCCPLUGIN_VERSION_MINOR `cut -d. -f2 $srcdir/BASE-VER` +#define GCCPLUGIN_VERSION_MICRO `cut -d. -f3 $srcdir/BASE-VER` +#define GCCPLUGIN_VERSION (GCCPLUGIN_VERSION_MAJOR*1000 + GCCPLUGIN_VERSION_MINOR) +#define GCCPLUGIN_DEVPHASE "$gcc_DEVPHASE" +#define GCCPLUGIN_REVISION "$gcc_REVISION" + static char basever[] = "$gcc_BASEVER"; static char datestamp[] = "$gcc_DATESTAMP"; static char devphase[] = "$gcc_DEVPHASE";