Reputation: 2357
I am trying to use macros to auto-generate the build version for a C++ project.
If I do the following, everything works fine.
Versioning.h
...
#define VERSION_MAJOR 1
#define VERSION_MINOR 0
...
MyApp.rc
...
#include "Versioning.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_MAJOR, VERSION_MINOR, 0, 0
PRODUCTVERSION VERSION_MAJOR, VERSION_MINOR, 0, 0
FILEFLAGSMASK 0x3fL
...
However, if I try and include anything more complex, such as math, the compiler generates errors
#define VERSION_MAJOR (2 / 2)
error RC1013: mismatched parentheses
error RC2104: undefined keyword or key name: /
I need to use much more complex mathematical expressions, call other classes, perform string comparison, etc. from within the macro.
My guess is that there is not something wrong with the macros I am writing, but rather a problem with the way that the resource file handles macros.
Any ideas?
Note: I am using Visual Studio Ultimate 2013 Update 3.
Upvotes: 1
Views: 2002
Reputation: 596041
A Resource compiler is not as flexible as a source code compiler. You cannot use complex macros in a resource script. If you need that, you will have to use a separate preprocessor to perform the calculations and generate the necessary macro values for the Resource compiler to use.
Upvotes: 1