Re: how to ensure #defines apply to all files in project?
Re: how to ensure #defines apply to all files in project?
- Subject: Re: how to ensure #defines apply to all files in project?
- From: Brian Stern <email@hidden>
- Date: Mon, 12 May 2008 17:07:34 -0400
On May 12, 2008, at 1:38 PM, Ken G. Brown wrote:
At 10:13 AM -0700 5/12/08, email@hidden
apparently wrote:
On May 11, 2008, at 8:41 PM, Ken G. Brown wrote:
I am attempting to compile an open source project in which a
config.h file sets up a bunch of #defines that control whether or
not other .c files in the project include certain files.
eg.
In one of the .c files
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
I have defined HAVE_CONFIG_H 1 as a user defined build setting for
all configurations but it does not get seen in the .c file.
I have put a #warning "message" in the #ifdef and it does not get
hit.
Use the 'Preprocessor Macros' build setting. Type in something like:
HAVE_CONFIG_H=1
This will correspond to -DHAVE_CONFIG_H=1 on the command line.
Just putting HAVE_CONFIG_H=1 by itself on the Preprocessor Macros
line results in the following errors:
<command line>:1:2: error: no macro name given in #define directive
<command line>:1:1: error: macro names must be identifiers
Works for me. Somehow you didn't enter it right in the build settings.
I'm using Xcode 2.5
I created a new project from stationery (Cocoa Application but it
doesn't really matter which one).
I opened the project build settings window and double clicked the
Preprocessor Settings line and a little window opened up.
I clicked the + button and entered the text from the following line
into the new setting:
HAVE_CONFIG_H=1
Clicked OK.
Entered the following text into the top of main.m
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
Compiled main.m and got the error: "error: config.h: No such file or
directory" as expected.
This is the command line:
Checking Dependencies
CompileC build/testdefine.build/Debug/testdefine.build/Objects-normal/
i386/main.o /Users/stern/develop/testdefine/main.m normal i386
objective-c com.apple.compilers.gcc.4_0
cd /Users/stern/develop/testdefine
/Xcode2.5/usr/bin/gcc-4.0 -x objective-c -arch i386 -pipe -Wno-
trigraphs -fpascal-strings -fasm-blocks -g -O0 -Wreturn-type -Wunused-
variable -DHAVE_CONFIG_H=1 -fmessage-length=0 -fzero-link -mfix-and-
continue -mmacosx-version-min=10.4 -I/Users/stern/develop/testdefine/
build/testdefine.build/Debug/testdefine.build/testdefine.hmap -F/Users/
stern/develop/testdefine/build/Debug -I/Users/stern/develop/testdefine/
build/Debug/include -I/Users/stern/develop/testdefine/build/
testdefine.build/Debug/testdefine.build/DerivedSources -isysroot /
Xcode2.5/SDKs/MacOSX10.4u.sdk -c /Users/stern/develop/testdefine/
main.m -o /Users/stern/develop/testdefine/build/testdefine.build/Debug/
testdefine.build/Objects-normal/i386/main.o
/Users/stern/develop/testdefine/main.m:12:20: error: config.h: No such
file or directory
If you look at the command line that was generated for you you should
probably be able to figure out what's wrong. Did you add any spaces
when adding the macro? Does your -D look wrong? Did you remove the
previous user defined build setting?
--
Brian Stern
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