Tomáš Zato
Tomáš Zato

Reputation: 53257

Why can I not use predefined constants in .rc file?

I want to make sure one cannot mix up 64 and 32 bit version of my DLL file. This is why I defined following preprocessor constant in the project properties:

image description

In my .rc file, I have these lines:

#ifdef x64 
  #define MY_PRODUCT_NAME = "My file 64bit"
#else
  #define MY_PRODUCT_NAME = "My file 32bit"
#endif

I want to use these constants in resource block below:

BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "000904b0"
        BEGIN
            VALUE "CompanyName", "SOMENAME"
            VALUE "FileDescription", "WHAT THIS FILE IS"
            VALUE "FileVersion", "1.0.0.1"
            VALUE "InternalName", "file.dll"
            VALUE "LegalCopyright", "Don't sell it pls"
            VALUE "ProductName", MY_PRODUCT_NAME
        END

On the line containing MY_PRODUCT_NAME, I get this compiler error:

1>  
1>StopThat.rc(58): error RC2133: unexpected value in value data
1>  
1>  
1>StopThat.rc(58): error RC2132: expected VALUE, BLOCK, or END keyword
1>  

This makes me real angry, because that's exactly what microsoft does in their documentation.

Am I doing something wrong? I guess I am, so what is it?

Upvotes: 0

Views: 1723

Answers (2)

Kirk
Kirk

Reputation: 11

Its because you are using an assignment operator in your macro definition, remove the "=" from your defines:

#ifdef x64 
  #define MY_PRODUCT_NAME "My file 64bit"
#else
  #define MY_PRODUCT_NAME "My file 32bit"
#endif

Upvotes: 1

user4578093
user4578093

Reputation: 229

Assuming that the code you posted is exactly equal to the code you tried to compile, I would say it might be that you are two END statements short of complete scoping, also I have never seen an equals sign in a #define statement.

To be sure though, I am no expert when it comes resource files.

Upvotes: 1

Related Questions