简体   繁体   English

LLVM为什么不使用Xcode编译pch文件中的typedeffed C块?

[英]Why doesn't LLVM compile typedeffed C blocks in pch file with Xcode?

I have typedeffed a C block type that I use commonly, in my project's PCH file: 我在项目的PCH文件中键入了常用的C块类型:

typedef void (^UserBlock)(PFUser* user);

When I try to define an Objective C method in a header like this: 当我尝试在标头中定义目标C方法时,如下所示:

+(void)ensureUserWithID:(NSString *)userID withCompletion:(UserBlock)completionHandler

I am getting Expected a type error on UserBlock . 我在UserBlockUserBlockExpected a type错误。 However, if I move the typedef from PCH to beginning of that header file, it compiles (with the warning Redefinition of typedef 'UserBlock' is a C11 feature . I've cleaned the build folder, deleted derived data, restarted Xcode, but I'm still getting the same error. I've got other definitions in my PCH too, and they are compiling just file. All I'm having trouble is the C block types defined in my PCH. Why am I encountering such behavior? I am on Xcode 5.1.1 and LLVM 5.1. 但是,如果我将typedef从PCH移到该头文件的开头,则会进行编译(警告Redefinition of typedef 'UserBlock' is a C11 feature 。我清理了构建文件夹,删除了派生数据,重新启动了Xcode,但是我“我仍然遇到相同的错误。我的PCH中也有其他定义,它们正在编译文件。我所遇到的麻烦是PCH中定义的C块类型。为什么会遇到这种行为?在Xcode 5.1.1和LLVM 5.1上。

Found the problem. 找到了问题。 The header file that I was getting errors on was imported to the PCH file, before the typedefs. 在typedef 之前 ,我遇到错误的头文件已导入到PCH文件。 I've moved the typedefs above the header import, and the problem was gone. 我已经将typedef移到了标头导入上方,问题就消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM