Information Technology Reference
In-Depth Information
Having a single source for these tokens would be useful, but they're scattered across many different locations.
For compiler-specific tokens, search online for “GCC preprocessor macros” and “LLVM preprocessor macros.”
For some of the Apple-specific tokens, search in Finder for the file TargetConditionals.h .
Creating custom tokens
Creating your own tokens is often useful—for example, you can add a token that's only defined when you se-
lect a custom configuration.
Note that it's a good idea to give your tokens a custom prefix; your initials are a popular option. Developers of-
ten add tokens to their code. If code is shared, simple names such as DEBUG and IPHONE can be defined in
multiple locations, creating conflicts.
1. Open a project with at least one custom configuration. Open the target build settings, and scroll
down the Other C Flags entry under the Language settings, as shown in Figure 13.27.
2. Click the entry to show the different configuration options.
3. Click the name of your custom configuration, and click the small + icon that appears to the right.
This adds a new token to the build settings.
4. Select Any Architecture | Any SDK from the floating menu at the left, and type -DMY_TOKEN into
the value field at the right to define the name and the value of the token.
If you select a specific SDK or architecture, the token is defined only when that SDK is active.
Figure 13.27
Adding a custom token. In this example MY_TOKEN is only defined when the My Debug configuration is
active.
Search WWH ::




Custom Search