Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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/Concatena
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:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.