[RESOLVED] How to use version number macros/definitions
I need to hide a function if product version 4.3.0 or lower is being used. A macro has been defined that I can use for this case as:
Code:
#define PRODUCT_VERSION ((PRODUCT_MAJOR_VERSION << 16) + (PRODUCT_MINOR_VERSION << 8) + PRODUCT_BUILDNUMBER)
I've printed the PRODUCT_VERSION for version 4.3.1 to console and seen that it translates to 262913 so I've used that number in a #if as shown below which is a working solution to my problem but it's also a bad and ugly solution. Is there a better way to work with this macro?
Code:
#if PRODUCT_VERSION>=262913
void troublesomefunction()
{
//code
}
#endif
Re: How to use version number macros/definitions
This is similar to how dealing with different windows versions work. See https://docs.microsoft.com/en-us/cpp...nd-win32-winnt
The small difference is that windows versions work on hex numbers - not decimal. So 262913 becomes 0x040301 and the text becomes
Code:
#if PRODUCT_VERSION>=0x040301
void troublesomefunction()
{
//code
}
#endif
You could also do it like this
Code:
#define PROD430 0x040300
#define PROD431 0x040301
#if PRODUCT_VERSION >= PROD431
void troublesomefunction()
{
//code
}
#endif
Re: How to use version number macros/definitions
I didn't realise it worked on hex, no wonder my decimal version number looked odd.
Thanks 2kaud :D