RE: Info.plist preprocessor macro expansion, space between tokens
RE: Info.plist preprocessor macro expansion, space between tokens
- Subject: RE: Info.plist preprocessor macro expansion, space between tokens
- From: "Alex Sheh" <email@hidden>
- Date: Mon, 1 May 2006 17:08:46 -0700
- Thread-topic: Info.plist preprocessor macro expansion, space between tokens
Hi Greg,
I looked at the detailed build output, and after running cpp on
Info.plist, Xcode runs gcc -E on Info.plist. I tried a simple header
file test and gcc -E is inserting the spaces around tokens.
I don't quite understand what the first cpp command is doing, as it
takes the installed Info.plist as the input header (which already has
version numbers substituted) and puts the output into a build folder
(which seems wholly unaffected, as it still contains the unexpanded
tokens). But the cpp man page does mention that "you cannot rely on it
preserving characteristics of the input which are not significant to
C-family languages", so this would explain why gcc -E is used later.
- Alex
-----Original Message-----
From: xcode-users-bounces+asheh=email@hidden
[mailto:xcode-users-bounces+asheh=email@hidden] On
Behalf Of Greg Guerin
Sent: Monday, May 01, 2006 3:25 PM
To: email@hidden
Subject: Re: Info.plist preprocessor macro expansion, space between
tokens
Alex Sheh wrote:
>Thanks, Greg. I did try some token concatenation experimentation. If
>I use ## in the Info.plist itself, it ignores the concatenation and
>instead outputs the '##'s themselves.
>
><string>MAJOR##.##MINOR##.##MICRO</string> results in 1##.##2##.##.3
When I run 'cpp' directly at the command-line, I get similar results. I
checked a reference man and it turns out both elements have to be legal
tokens, and "." isn't one.
However, the following simple macro replacement works with cpp, and
doesn't inject any unwanted white-space:
#define MAJOR 1
#define MINOR 2
echo MAJOR.MINOR
which expands to:
echo 1.2
along with some lines that start with "#". Maybe you should check that
your #define's don't have extra white-space in them.
Also, it seems cpp doesn't stringize tokens like it should (#token ends
up being output as literal #token, rather than being double-quoted).
The example macro-defn of COMMAND(NAME) given at the following URL
simply does not work as documented.
<http://developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/cpp/C
oncatena
tion.html>
Nor does this example from another source:
#define TEMP(i) temp ## i
TEMP(1) = TEMP(2)
which is expanded to:
temp ## 1 = temp ## 2
It almost looks like cpp is relying on a subsequent C compiler pass to
finish doing its token pasting.
I suspect cpp may be slightly broken, or there is some subtle context
I'm missing. You might want to look at the detailed build info to find
out exactly what command and args are being used to perform the
preprocessing pass on the plist.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden