user967007
user967007

Reputation:

c preprocessor to determine project or exe name

I have a C resource file called resources.rc, which contains the following line to specify the icon used for a project

    1000 ICON  "icon222.ico"

I would like to use this same resource file for several projects using a pre processor conditional depending on the project..

e.g

    #if __PROJECT__ == "myapp.exe"
    1000 ICON "icon222.ico"
    #endif

    #if __PROJECT__ == "myotherapp.exe"
    1000 ICON "icon777.ico"
    #endif

Is there a standard C macro or definition that could be used to achieve something like this ?

Upvotes: 1

Views: 1710

Answers (1)

alk
alk

Reputation: 70981

As far as I known there is no predefined macro carring a project specific value setup by VC.

So just select one yourself like MYPROJECTNAME and #define it differently in each of your projects and then do test this in your rc file as by your posting.

I'm not sure anymore whether VC uses the pre-processor on the rc file automagically or if you need to apply some mods to VC's build process to have it do this.


Update:

To have this feature added using ${EXENAME} in terms of having global (solition wide) settings for VC a way to go might be shown here: Visual c++ 2008: how to have global settings defined in a solution or/and here: Can I pass a preprocessor definition to the resource compiler through the command line?

Upvotes: 1

Related Questions