我们正在为我们的iPhone应用程序添加CoreData支持。这是一个深远的变化(从SQLitePersistentObject移动)。为避免分支,我们使用#ifdef
块内的新代码运行单个代码行。使用CPP定义构建pch文件时出错
当我从我的头文件(#define CORE_DATA_BUILD)启用此代码时,一切正常。当我创建一个新目标并在那里定义我的预处理器宏时,系统头文件中会出现错误。特别; CFBag.h,CFArray.h,CFBinaryHeap.h,CFDictionary.h和CFSet.h都无法编译。
错误是:
expected ';', ',' or ')' before '>' token
我通过复制我的现有应用的目标,然后加入CORE_DATA_BUILD到GCC-4.2的Ç预处理器定义部分创建的我的新的目标 - 预处理。
我很确定预处理器定义已设置,并且我的宏名称不与任何Apple符号冲突。当我将我的定义添加到“预编译头中未使用预处理器宏”时,该错误也会显示出来。我已经清除了构建并删除了预编译头文件,但仍然出现错误。
调用和错误输出从Xcode是:
ProcessPCH /var/folders/Ay/AyBvIizJERGjIMkWxjcIfU+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/UIKit-fzghyhumbyslqcedmtegbkgafwpy/UIKit.h.gch /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h normal i386 objective-c com.apple.compilers.gcc.4_2
cd /Users/rog/Development/Groove
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -x objective-c-header -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Werror -Wreturn-type -Wunused-variable -DCOREDATA -D<Multiple -Dvalues> -D__IPHONE_OS_VERSION_MIN_REQUIRED=30000 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2 -iquote /Users/rog/Development/Groove/build/Groove.build/Debug-iphonesimulator/Tests.build/Tests-generated-files.hmap -I/Users/rog/Development/Groove/build/Groove.build/Debug-iphonesimulator/Tests.build/Tests-own-target-headers.hmap -I/Users/rog/Development/Groove/build/Groove.build/Debug-iphonesimulator/Tests.build/Tests-all-target-headers.hmap -iquote /Users/rog/Development/Groove/build/Groove.build/Debug-iphonesimulator/Tests.build/Tests-project-headers.hmap -F/Users/rog/Development/Groove/build/Debug-iphonesimulator -F/Users/rog/Development/Groove -I/Users/rog/Development/Groove/build/Debug-iphonesimulator/include -I/Users/rog/Development/Groove/build/Groove.build/Debug-iphonesimulator/Tests.build/DerivedSources/i386 -I/Users/rog/Development/Groove/build/Groove.build/Debug-iphonesimulator/Tests.build/DerivedSources -c /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h -o /var/folders/Ay/AyBvIizJERGjIMkWxjcIfU+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/UIKit-fzghyhumbyslqcedmtegbkgafwpy/UIKit.h.gch
<command-line>: error: macro names must be identifiers
<command-line>: error: ISO C99 requires whitespace after the macro name
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:39,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:8,
from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:9:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFArray.h:173: error: expected ';', ',' or ')' before '>' token
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFArray.h:359: error: expected ';', ',' or ')' before '>' token
In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:40,
etc...
我Prefix.pch文件是标准:
//
// Prefix header for all source files of the 'Groove' target in the 'Groove' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
任何想法是怎么回事?
Doh,我完全没有注意到:-(非常感谢,我不知道我是怎么做到的,但今天很快调查,我注意到当我试图删除我的COREDATA宏时,Xcode没有覆盖设置 – 2009-06-07 21:22:35