Reputation: 2484
I made an application, and i have to create two separete builds for it. One for 32bit and one for 64bit. In the property of the file, i'd like to include some descriptions, like the original filename, where i'd like to set the architecture(x64 or x86). As it seems it is harder than i thought, or i am doing something wrong.
#ifdef _WIN64
#define ARCHIT "1"
#else
#define ARCHIT "2"
#endif
This macro always returns 2. Am i doing something wrong? If i insert some #pragma message
before the define
i see, that is evaluating correctly, but somehow the text written in the file property will always be 2.
Could someone help me?
Thanks!
Update:
This is how i use it:
#define VER_FILEVERSION 1,0,0,0
#define VER_FILEVERSION_STR "1.0.0.0\0"
#define VER_PRODUCTVERSION 1,0,0,0
#define VER_PRODUCTVERSION_STR "1.0.0.0\0"
1 VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "My Description"
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", BASENAME
VALUE "LegalCopyright", "My company"
VALUE "OriginalFilename", ARCHIT
VALUE "ProductName", BASENAME
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
Upvotes: 2
Views: 1131
Reputation: 2484
Thanks for everyone, but for me, this was the Solution. I think that's the simplest.
Update:
Detailed description, in case the link isn't working:
1. Open your project in Visual Studio.
2. Right click on resource script file (e.g. app.rc) and select "Properties"
3. At the top of the property page, select one platform like "Win32" or
"x64".
4. In the left menu bar, select [Configuration Properties] / [Resources] /
[General].
5. In the "Preprocessor Definitions" field, add "WIN32" for "Win32"
platform and "WIN64" for "x64" platform. The field value will become "
WINXX;_UNICODE;UNICODE". (XX will be 32 or 64)
6. Click OK to close the window.
7. Right click on resource script file (e.g. app.rc) and select "View Code".
8. In the code editor, add #ifdef and #elif to conditionally include
resources when compiling.
Upvotes: 0
Reputation: 16769
From the comments and from MSDN it seems that the only predefined macro in RC scripts is RC_INVOKED. So, you can't automatize RC scripts. There are however T4 text templates, and their .tt scripts. With them you could create some kind of .rc2 scripts that would #define
anything you need, and that you would then #include
in .rc script.
Should work in theory, never tried it though.
There is a page that explains how to automatically generate code with T4 scripts, and according to that page you need to install a Modelling SDK for your Visual Studio (2010, 2012, 2013). Unfortunately, it's not available for older versions.
Upvotes: 1