On Wed, Jul 6, 2011 at 2:50 PM, Basile Starynkevitch
<bas...@starynkevitch.net> wrote:
> 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'd say exposng major, minor and patchlevel (instead of micro)
should be enough.  Similar to what the host compiler gives you
via __GNUC__, __GNUC_MINOR__ and __GNUC_PATCHLEVEL__.

Richard.

> 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} ***
>

Reply via email to