From: David Webber on
My .rc files use definitions common to them and the .cpp files.

These definitions are in header files included by both.

However, it is convenient for these headers sometimes also to contain
things like structure definitions and inline functions which are irrelevant
to the rc files, and may cause problems for the rc compiler.

Now I could insert above the inclusions in the rc file

#define THIS_IS_AN_RC_FILE

and then within the headers put

#if !defined THIS_IS_AN_RC_FILE
// all the stuff I don't want the rc file to see
#endif

but it occurs to me that the rc compiler might automatically define
something equivalent.

Does it?

Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm

From: Alex Blekhman on
"David Webber" wrote:
> but it occurs to me that the rc compiler might automatically
> define something equivalent.
>
> Does it?

Yes, it defines `RC_INVOKED' macro:

"Predefined Macros"
http://msdn2.microsoft.com/en-us/library/aa381032(vs.85).aspx

HTH
Alex


From: Tom Serface on
Hi David,

I see Alex already answered you question, but if you manually modify the .RC
file you may have problems if you use the RC editor to add or remove
resources in the future since it takes liberties in rewriting the file. I
typically do "extra" things in the .RC2 file that is created since there is
no way of controlling how the editor rewrites the .RC file. It does include
the .RC2 file automatically so that is a handy place to do your own things.
You may already know this, but I figured I'd throw it out anyway...

Tom

"David Webber" <dave(a)musical-dot-demon-dot-co.uk> wrote in message
news:Oq1GkkUpIHA.4620(a)TK2MSFTNGP06.phx.gbl...
> My .rc files use definitions common to them and the .cpp files.
>
> These definitions are in header files included by both.
>
> However, it is convenient for these headers sometimes also to contain
> things like structure definitions and inline functions which are
> irrelevant to the rc files, and may cause problems for the rc compiler.
>
> Now I could insert above the inclusions in the rc file
>
> #define THIS_IS_AN_RC_FILE
>
> and then within the headers put
>
> #if !defined THIS_IS_AN_RC_FILE
> // all the stuff I don't want the rc file to see
> #endif
>
> but it occurs to me that the rc compiler might automatically define
> something equivalent.
>
> Does it?
>
> Dave
> --
> David Webber
> Author of 'Mozart the Music Processor'
> http://www.mozart.co.uk
> For discussion/support see
> http://www.mozart.co.uk/mozartists/mailinglist.htm

From: David Webber on

"Alex Blekhman" <tkfx.REMOVE(a)yahoo.com> wrote in message
news:%23ZH503UpIHA.1768(a)TK2MSFTNGP03.phx.gbl...

> "David Webber" wrote:
>> but it occurs to me that the rc compiler might automatically define
>> something equivalent.
>>
>> Does it?
>
> Yes, it defines `RC_INVOKED' macro:
>
> "Predefined Macros"
> http://msdn2.microsoft.com/en-us/library/aa381032(vs.85).aspx

Brilliant thanks! I guessed there should be one.

Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm

From: David Webber on

"Tom Serface" <tom.nospam(a)camaswood.com> wrote in message
news:B32B0FD9-1BA3-4A48-A357-DB41A283D700(a)microsoft.com...

> I see Alex already answered you question, but if you manually modify the
> .RC file you may have problems if you use the RC editor to add or remove
> resources in the future since it takes liberties in rewriting the file. I
> typically do "extra" things in the .RC2 file that is created since there
> is no way of controlling how the editor rewrites the .RC file. It does
> include the .RC2 file automatically so that is a handy place to do your
> own things. You may already know this, but I figured I'd throw it out
> anyway...

Thanks Tom,

I'm an old hand at massaging rc files and rc2 files - and at cursing the
resource editor - and usually get what I deserve :-)

For example:

One thing I spent a lot of time with was having #defines for the numbers in
the VERSION INFO (in th rc2 file!) so that I can change the version number
in a header file, and all my DLLs build with a common version number. The
problem IIRC was getting the integer and string versions to match with only
one #define for each component of the version number. It's a bit of an art,
as it appeared to me at the time that the resource compiler does not
respect ALL preprocessor definitions which the CPP compiler does.

In the end, my versioninfo definitions have almost nothng but #define'd
entries.

The appended header definitions seem to work, but I never worked out why
both _STR and STR are needed. I didn't work without them!

Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm


// For version 10.0.0.31:
// Stringisation.
// For some reason the two-step definitions below work when it doesn't with
a single
// step.

#define _STR(x) #x
#define STR(x) _STR(x)

// The following are used as defined quantities in the versioninfo resource:

#define VERMAJ 10
#define VERMIN 0
#define VERFIX 0
#define BUILDNUMBER 31 // See also VERSIONINFO.

#define VERMAJSTR STR( VERMAJ )
#define VERMINSTR STR( VERMIN )
#define VERFIXSTR STR( VERFIX )
#define BUILDSTR STR( BUILDNUMBER ) // Used to build stings below.

#define VERSIONSTRING VERMAJSTR "." VERMINSTR "." VERFIXSTR "." BUILDSTR
#define PRODUCTSTRING VERMAJSTR "." VERMINSTR "." VERFIXSTR "." BUILDSTR

===