testing build setting value in prefix file at compile time
testing build setting value in prefix file at compile time
- Subject: testing build setting value in prefix file at compile time
- From: Steve Caine <email@hidden>
- Date: Thu, 17 May 2007 19:04:52 -0400
Hello,
How can I set compile-time flags in a header file so they will be
"on" in debug builds but "off" in release builds?
This code started life in CodeWarrior, where I can use
#if __ide_target("Debug")
to check the name of the target being built.
I'd like to check the value of an Xcode build setting such as
GCC_GENERATE_DEBUGGING_SYMBOLS to get the same behavior, such in the
example below (on the line with "?????").
// config_flags.h
// IS THIS DEBUG OR RELEASE BUILD?
#ifdef __MWERKS__
# if __ide_target("Debug")
# define _DEBUG
# endif
#elif __GNUC__
# if ?????
# define _DEBUG
# endif
#elif defined(_MS_VER)
// Visual Studio #define's _DEBUG for us
#endif
#ifdef _DEBUG
// do something appropriate for the debug build
#else
// do something appropriate for the release build
#endif
I've tried
#if GCC_GENERATE_DEBUGGING_SYMBOLS
#if $GCC_GENERATE_DEBUGGING_SYMBOLS
and even
#if $(GCC_GENERATE_DEBUGGING_SYMBOLS)
knowing that $(...) can be used to substitute build settings values
for strings in my Info.plist file, but the first two are treated as
an undefined symbol (i.e., treated as 0) while the third gets
error: missing binary operator before token "("
Apple's "Moving Projects To Xcode" documentation says I can "define
preprocessor options in the target settings ... for example, to
define a master debug flag you can test for anywhere in your code",
but I can't find any illustration of how that would work. How would I
define such a flag so that it could be tested at compile time?
Here's the full quote, taken from
http://developer.apple.com/documentation/DeveloperTools/Conceptual/MovingProjectsToXcode/migration_differences/chapter_2_section_18.html,
starting with the third paragraph after the "Creating Debug and
Non-Debug Products" heading.
In both CodeWarrior and Xcode, you can define a common prefix file
that includes all the headers needed by a project to create debug or
non-debug products. You can then define separate headers that set
required preprocessor definitions (for example, #define debug 1),
then include the appropriate header into the prefix file, depending
on which type of product you want to build.
In CodeWarrior, this requires separate prefix files because the only
way to set a macro is with a #define statement in a file (you can't
set values on a command line).
In Xcode, you can take another approach. You can have one common
prefix file for all targets. You can then define preprocessor
options in the target settings. This allows you, for example, to
define a master debug flag you can test for anywhere in your code.
Since it's part of the target settings, the prefix file will be
precompiled differently, depending on the target settings for the
product.
Any help people could offer here would be much appreciated.
Steve Caine
independent developer
writing XTensions to QuarkXPress since 1991
_______________________________________________
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