[BuildTools] Proposal: XXX_SVN_REV change from quoted string to numeric
Stefan Vigerske
stefan at math.hu-berlin.de
Thu Sep 2 12:59:10 EDT 2010
Hi,
> One of the SCIP developers has run into a problem trying to identify
> exactly what version of clp is available. In particular, he needs to be able to
> discriminate between revisions of the trunk, because of changes that are not
> backward compatible combined with additions of new features.
>
> What he needs is a numeric constant to examine at compile time (as
> opposed to a character string). XXX_VERSION is useless in trunk; it's set as
> #define XXX_VERSION "trunk"
> Even in stable or release, it's problematic because it's a quoted string.
> His proposal was to define a new constant
> #define XXX_NUMERIC_VERSION 42
> My objection, at least at the level of trunk, is that this will require manual
> fussing. I countered by suggesting XXX_SVN_REV, which is meaningful for trunk,
> stable, and release.
But I'm not so sure that this will be useful for him, because changes to
old stables will also bump up the XXX_SVN_REV, so he cannot do something
like
#if XXX_SVN_REV >= 42
// use new infeasible ray ... (my guess ;-))
#endif
> But it needs to change from
> #define XXX_SVN_REV "42"
> to
> #define XXX_SVN_REV 42
> (note the absence of quotes, so that it expands to a number that can be compared
> at compile time). This change requires a bit of fussing in coin.m4 to make sure
> that some of the more exotic output from svnversion is boiled down to a single
> number, but that's no big thing.
>
> Does anyone see a hazard? If not, I will commit this change to
> BuildTools/trunk tomorrow (Sep. 3).
Apart from the above, having the revision number not quoted is a good
thing, I believe. Since it is always a number, it makes sense to have it
accessible as a number.
> Looking a bit further afield, what about XXX_VERSION? Are people using
> it in a way that requires quoting the value? I can see a much larger potential
> for problems with removing the quotes here.
One could make XXX_VERSION unquoted and define an XXX_VERSION_QUOTED for
convenience:
http://en.wikipedia.org/wiki/C_preprocessor#Indirectly_quoting_macro_arguments
So you could make this SCIP developer believe that he can write
#if CLP_VERSION >= 113 /* ??? */
to recognize when the changes he need made it into a stable version.
For trunk's, one may set the numerical XXX_VERSION to -1 or something
like that?
Stefan
--
Stefan Vigerske
Humboldt University Berlin, Numerical Mathematics
http://www.math.hu-berlin.de/~stefan
More information about the BuildTools
mailing list