Re: Headers common to .cpp and .rc files

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Tom Serface" <tom.nospam@xxxxxxxxxxxxx> wrote in message news:B32B0FD9-1BA3-4A48-A357-DB41A283D700@xxxxxxxxxxxxxxxx

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

===

.



Relevant Pages

  • Re: Problems with LoadString when using MBCS (Multi Byte Character Set)
    ... block from the .rc file to the .rc2 file. ... > language-specific, using VC resource editor, one by one, and then moved ... what about the resource string editor? ...
    (microsoft.public.vc.mfc)
  • Re: Dialogeditor
    ... wenn du den Dialog Editor nutzen mußt: kreiere eine .RC Datei per Hand ... Dialogeditor erzeugt ja eine .DLG und eine .RES Datei). ... Es ist dann zwar nach wie vor so, daß bei jedem Arbeiten der Dialog Editor ... nebenbei), aber du kannst jederzeit die KOMPLETTE Resource erzeugen, indem ...
    (de.comp.os.os2.programmer)
  • Re: dynamic menu question
    ... If you define IDR_DYNA in the resource ... editor, it will be ... delete it from the map. ... I just need find a way to give that menu IDR_ identifier somehow... ...
    (microsoft.public.vc.mfc)
  • Re: dynamic menu question
    ... Create a menu at design time and load it dynamically, ... a menu from the resource segment. ... editor, it will be ... delete it from the map. ...
    (microsoft.public.vc.mfc)
  • Re: cant see my menu item
    ... >I edited the resources file with a text editor and I saw that there ... >that the identifier constant of the item was not defined on it. ... The resource editor will probably undo this work. ... remembers everything it understands and discards the rest ...
    (microsoft.public.windowsce.embedded.vc)