views:

481

answers:

1

Are there some preprocessor keywords to use to access the FILEVERSION defined in my .rc file at compile time?

I don't really want to add extra code to read the file information from the compiled product itself.

+3  A: 

The preprocessor runs on the .RC file as well. Define the shared data in a header that is included by both the .RC and your source code.

i.e., in foo.h:

#define MY_PRODUCT_NAME Foo

Then in the foo.rc:

#include "foo.h"

VS_VERSION_INFO VERSIONINFO
   // Many lines omitted
   VALUE "ProductName", MY_PRODUCT_NAME

Then in foo.cpp:

#include "foo.h"

cout << MY_PRODUCT_NAME;
Michael
Good idea, but in the RC file it has a string block of information which also has the version info (in a slightly different format). Any way to simply access the RC file values rather than re-defining them and keeping them in a common place?
known
None that I know of - rc.exe is independent of cl.exe.
Michael