문제

I'm working on creating build configurations based on a previous question of mine. I've got the Build Configurations created, and I have conditional declarations for the different builds in a file called custom.h. It currently looks like this:

#pragma once

#if defined(ELITE_BUILD)
    #define BUILD 3 // 1: personal, 2: select, 3: elite
#elif defined(SELECT_BUILD)
    #define BUILD 2
#elif defined(PERSONAL_BUILD)
    #define BUILD 1
#endif

In one of my .rc files there is an include for versionconfig.h that looks like this (somewhat redacted):

#if BUILD == 1
#define STRDESCRIPTION  "Personal Edition"
#elif BUILD == 2
#define STRDESCRIPTION  "Select Edition"
#elif BUILD == 3
#define STRDESCRIPTION  "Elite Edition"
#pragma message(STRDESCRIPTION)
#endif

I added the #pragma command as a logging effort. After that include, the relevant parts of the .rc file looks like this (again, a bit redacted for brevity):

BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "FileDescription", STRDESCRIPTION
        END
    END
END

When I attempt to compile this project I get the error error RC2104 : undefined keyword or key name: STRDESCRIPTION. I'm at a bit of a loss. The value exists, I can log it immediately after setting it, and there is no #undef command for it.

-- EDITED --

If I add placeholder defines outside of the if block the project will compile, but the values aren't showing up, so my problem appears to be related to conditional definitions. What's confusing me most at this point is that I can put a #pragma message command inside the conditional block and it's executed properly, but the values defined there are non-existent. Hoping someone can shed some light on this for me.

도움이 되었습니까?

해결책

I found it. In Visual Studio you have to set pre-processor definitions for the Resource Files separately from the Project. As soon as I added ELITE_BUILD to the pre-processor section for the resource everything worked as expected.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top