Getting and testing JUCE version number


#1

Is there any quick way to test if the juce version is superior or equal to a specific one?
It would be handy to have a macro to test that.

It would notably be useful when functions are deprecated, as we often work on modules/generic codes that are potentially used with different juce versions.
We could then use that macro to check if we can call the new code or if we still need to call the deprecated function :

#if IS_JUCE_VERSION_SUP_OR_EQUAL_TO (5, 3, 3)
    theNewFunction();
#else
    theDeprecatedFunction();
#endif

What do you think?

perhaps something like that?

#define GET_JUCE_VERSION_NUMBER(major, minor, build) ((major << 16) + (minor << 8) + build)

#define JUCE_VERSION  GET_JUCE_VERSION_NUMBER (JUCE_MAJOR_VERSION, JUCE_MINOR_VERSION, JUCE_BUILDNUMBER)

#define IS_JUCE_VERSION_SUP_OR_EQUAL_TO(major, minor, build) JUCE_VERSION >= GET_JUCE_VERSION_NUMBER(major, minor, build)

#2

Yes, that’d be a nice addition, though you could also write it using hex, like this

if (JUCE_VERSION >= 0x050301)

#3

ah, yes, neat!
(but 0x050301, not 0x531 )


#4

Oh yes, oops! (I’ll correct my earlier post in case anyone uses it!)