[Mono-dev] gmcs version #define
jonpryor at vt.edu
Wed Nov 11 11:22:02 EST 2009
On Wed, 2009-11-11 at 17:22 +0200, Stefanos A. wrote:
> According to the documentation, gmcs #defines the __MonoCS__ constant
> when compiling C# code. However, it doesn't seem to provide a constant
> that identifies the compiler version.
> Does this sound like a reasonable feature? Would it be possible to add a
> constant like "#define __MonoVersion__ 260" in some future version?
> (where 260 is gmcs 2.6.0, 281 is gmcs 2.8.1, etc)
The problem here is that C# #defines can't have values, so you can't do
`#define __MonoVersion__ 260`. Instead, you would need to have a
"family" of #defines with the version encoded in the name, e.g.
__MonoCS_200__, __MonoCS_220__, __MonoCS_240__, etc., and I'm not sure
that would be very useful (as you couldn't have `#if __MonoCS__ > 260`
blocks, but instead `#if __MonoCS_260__ && !__MonoCS_240__` or
something, which relies on answering this: should gmcs 2.6 define *both*
__MonoCS_260__ AND __MonoCS_240__, or just __MonoCS_260__?).
My gut feeling is that this can't actually be solved easily within C#
source; you'd instead need to move the logic into e.g. make(1), and use
`#if BNC_XXXXXX`  in your source, and in your Makefile add
-d:BNC_XXXXXX if `mcs --version` is a known bad version.
 Why BNC_XXXXXX? Bugzilla.Novell.Com with XXXXXX as the bugzilla ID
number. Replace BNC with the appropriate bugzilla abbreviation, as
appropriate. Great fun, and lets you know when you can stop using the
More information about the Mono-devel-list