当前位置 : 主页 > 手机开发 > ios >

xcode – 使用CPP定义构建pch文件时出错

来源:互联网 收集:自由互联 发布时间:2021-06-11
我们正在为我们的iPhone应用添加CoreData支持.这是一个影响深远的变化(从SQLitePersistentObject转移).为了避免分支,我们在#ifdef块中使用新代码运行单个代码行. 当我从我的一个标题(#define CO
我们正在为我们的iPhone应用添加CoreData支持.这是一个影响深远的变化(从SQLitePersistentObject转移).为了避免分支,我们在#ifdef块中使用新代码运行单个代码行.

当我从我的一个标题(#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

知道出了什么问题吗?

-D<Multiple -Dvalues> 
<command-line>: error: macro names must be identifiers
<command-line>: error: ISO C99 requires whitespace after the macro name

在某些时候,您似乎编辑了项目或目标的预处理器宏构建设置的所有配置.不同的配置具有不同的值.不是按下取消或统一替换它们,而是以某种方式确认了占位符文本.

Xcode尽职尽责地传递“< Multiple”和“Values>”作为预处理程序定义,而不是您想要的预处理程序定义.

转到目标检查器“构建”选项卡,找到“预处理器宏”,删除其当前值,并将其替换为您真正想要的值.

网友评论