Re: Headers common to .cpp and .rc files
- From: "David Webber" <dave@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 28 Apr 2008 15:55:09 +0100
"Alex Blekhman" <tkfx.REMOVE@xxxxxxxxx> wrote in message news:uw2Wf9spIHA.3408@xxxxxxxxxxxxxxxxxxxxxxx
You can conduct simplest experiment with following text file:> Open it with any text editor and do search-and-replace while
-------
#define _STR(x) #x
#define STR(x) _STR(x)
#define BUILDSTR STR( BUILDNUMBER )
#define BUILDNUMBER 31
counting how many times you perform the operation. After each search-and-replace remove the #define that was used (it will be corrupted by the editor anyway). Any time you get #some_token replace it with "some_token" regardles of what `some_token' name may mean.
You'll see the exact flow of the preprocessor.
Ok. I can do that in my head :-) Sorry if I'm being thick here, but I still can't see it.
Sequence 1:
#define _STR(x) #x
#define STR(x) _STR(x)
#define BUILDSTR STR( BUILDNUMBER )
#define BUILDNUMBER 31
.... = BUILDSTR;
Pass 1 gives
#define STR(x) #x
#define BUILDSTR STR( BUILDNUMBER )
#define BUILDNUMBER 31
.... = BUILDSTR;
Pass 2 gives
#define BUILDSTR #BUILDNUMBER
#define BUILDNUMBER 31
.... = BUILDSTR;
Pass 3 gives
#define BUILDNUMBER 31
....= #BUILDNUMBER;
Now two possibilities:
A). Assuming BUILDNUMBER is replaced next, then
....= #31;
and so
....="31";
B) However, if after pass 3, the #-operator were expanded then I get
#define BUILDNUMBER 31
....= "BUILDNUMBER";
and the #define will not replace the contents of the quotes.
But this works correctly and so possibility 2 is not happening.
One could therefore argue that it is just done in order, Except
Sequence 2:
#define STR(x) #x
#define BUILDSTR STR( BUILDNUMBER )
#define BUILDNUMBER 31
.... = BUILDSTR;
you get the same results. But sequence 1 works and sequence 2 doesn't. There must be something going on other than just a sequence of independent passes.
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
.
- Follow-Ups:
- Re: Headers common to .cpp and .rc files
- From: Alex Blekhman
- Re: Headers common to .cpp and .rc files
- From: Ben Voigt [C++ MVP]
- Re: Headers common to .cpp and .rc files
- References:
- Headers common to .cpp and .rc files
- From: David Webber
- Re: Headers common to .cpp and .rc files
- From: Tom Serface
- Re: Headers common to .cpp and .rc files
- From: David Webber
- Re: Headers common to .cpp and .rc files
- From: Alex Blekhman
- Re: Headers common to .cpp and .rc files
- From: David Webber
- Re: Headers common to .cpp and .rc files
- From: Alex Blekhman
- Re: Headers common to .cpp and .rc files
- From: David Webber
- Re: Headers common to .cpp and .rc files
- From: Alex Blekhman
- Headers common to .cpp and .rc files
- Prev by Date: Re: passing vector as argument
- Next by Date: Re: member function level dll export
- Previous by thread: Re: Headers common to .cpp and .rc files
- Next by thread: Re: Headers common to .cpp and .rc files
- Index(es):
Relevant Pages
|