minwin

Bill Baxter dnewsgroup at billbaxter.com
Wed Nov 29 00:11:09 PST 2006


Walter Bright wrote:
> Bill Baxter wrote:
>> Here's wxWidgets version macro for checking the version of wxWidgets 
>> you're compiling with.  It should be possible to get the same effect 
>> in D somehow:
>>
>> /*  check if the current version is at least major.minor.release */
>> #define wxCHECK_VERSION(major,minor,release) \
>>     (wxMAJOR_VERSION > (major) || \
>>     (wxMAJOR_VERSION == (major) && wxMINOR_VERSION > (minor)) || \
>>     (wxMAJOR_VERSION == (major) && wxMINOR_VERSION == (minor) && 
>> wxRELEASE_NUMBER >= (release)))
> 
> To ask the obvious dumb question, why? If I was to see such, I'd wonder 
> what purpose wxCHECK_VERSION was being used for. I presume it is to 
> enable/disable certain things.
> 
> I suggest instead to either:
> 
> 1) create version identifiers for those "certain things" like 
> wxFEATURE_FOO_IS_WORKING

That's great if the wx developers put that in for me, but if they didn't 
then the wx release number is the only info you have to determine if 
FEATURE_FOO_IS_WORKING.  So you'll end up with basically this in your 
"version features" module:

static if(wxCHECK_VERSION > 20603) {
    version = FEATURE_FOO_IS_WORKING
}

The need for checking against a version didn't go away, it just moved 
into the module.

If that's the way one is supposed to use 'version' then I'm ok doing 
that.  Just seems like both kinds of checks are about versions, so it 
should all be in a version() check, rather than some things static if(), 
some things version().

> 
> 2) create an api for those features and abstract them into other modules
> 
> 3) wxVERSION_NUMER already combines the values into one integer. Use 
> that integer instead as the overall version number.

--bb



More information about the Digitalmars-d-announce mailing list