c++visual-studiowinapiconditional-compilationresource-files

#ifdef x64 does not work for windows resource file


Recently, I have been trying to get a DLL to have a different InternalName and OriginalFilename based on what platform it is compiled as. If the DLL is set to Release|x64 it should have one name, and if set to Release|x86 it should have another. I use to just have 2 different projects, but felt it was easier to just create an ifdef. The problem is no matter what I do, the InternalName and OriginalFilename ALWAYS end up being the x86 name.

Below I have a small snip from my Resource.h file where I store the ifdef.

The snippet below that is from the dlls .rc file where that detail is defined.

#ifdef WIN64
    // 64 bit windows
    #define DLLNAME                     "MyDLL.dll"
#else
    // 32 bit windows
    #define DLLNAME                     "MyDLL_WIN32.dll"
#endif // _WIN64 or _WIN32
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "CompanyName", "Software Company Inc."
            VALUE "FileDescription", "Some DLL"
            VALUE "FileVersion", "1.0.0.1"
            VALUE "InternalName", DLLNAME
            VALUE "LegalCopyright", "Copyright (C) 2019.  All rights reserved."
            VALUE "OriginalFilename", DLLNAME
            VALUE "ProductName", "Some DLL"
            VALUE "ProductVersion", "1.0.0.1"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

Here are the Preprocessor Definitions I have set.

Preprosseor for X64

Preprosseor for X86

Any help for what I am doing wrong would be great.


Solution

  • If you check the properties on the .RC file, you'll see that it does not inherit the preprocessor definitions used for the C++ compiler.

    You'll have to explicitly add the WIN64 definition to the .RC file's options for each configuration that needs it.