Xcode 4:“错误:未知类型名称‘BOOL’;您的意思是‘BOOL’吗?”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7751411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 4: "error: unknown type name 'BOOL'; did you mean 'BOOL'?"
提问by jww
I have a project which worked great under Xcode 3.2.x. Under Xcode 4.2, I'm getting the following error when compiling:
我有一个在 Xcode 3.2.x 下运行良好的项目。在 Xcode 4.2 下,编译时出现以下错误:
"error: unknown type name 'BOOL'; did you mean 'BOOL'?"
I can right click on the offending BOOL
and Xcode will jump to Apple's definition. BOOL
is defined in <objc/objc.h>
, so I included it in my source file (despite the fact that I'm using precompiled headers with UIKit.h and Foundation.h). Still no joy - the compile error persists.
我可以右键单击有问题的BOOL
,Xcode 将跳转到 Apple 的定义。BOOL
在 中定义<objc/objc.h>
,所以我将它包含在我的源文件中(尽管我使用带有 UIKit.h 和 Foundation.h 的预编译头文件)。仍然没有快乐 - 编译错误仍然存在。
Any ideas for Xcode 4 work arounds would be appreciated. Google is offering 0 hits.
任何有关 Xcode 4 解决方法的想法都将不胜感激。Google 提供 0 次点击。
EDIT: added the offending code to remove any ambiguity.
编辑:添加了违规代码以消除任何歧义。
// AppConstants.h
typedef enum { ThreadPriorityLow = NSOperationQueuePriorityLow, ThreadPriorityNormal = NSOperationQueuePriorityNormal,
ThreadPriorityHigh = NSOperationQueuePriorityHigh, ThreadPriorityDefault = ThreadPriorityNormal } ThreadPriority;
static inline BOOL IsValidThreadPriority(ThreadPriority priority)
{
return priority == ThreadPriorityLow || priority == ThreadPriorityNormal || priority == ThreadPriorityHigh;
}
EDIT: after looking at the source under Emacs and HexFiend for illegal characters and finding none (source is 8-bit clean), I'm inclined to believe this is due to some kind of bug on Apple's part.
编辑:在查看 Emacs 和 HexFiend 下非法字符的来源并没有发现(来源是 8 位干净的)之后,我倾向于相信这是由于 Apple 方面的某种错误。
采纳答案by jww
It was broken Apple software.
它是损坏的Apple软件。
Apple disregarded my 3.2.6 projects settings and decided to use the LLVM 3.0 suite rather than GCC 4.2. Previously (under Xcode 3.2.6), I had specifically set the project to use GCC due to my extensive use of GCC warnings and flags.
Apple 无视我的 3.2.6 项目设置并决定使用 LLVM 3.0 套件而不是 GCC 4.2。以前(在 Xcode 3.2.6 下),由于我广泛使用 GCC 警告和标志,我专门将项目设置为使用 GCC。
After I changed 'Build Settings' -> 'Compile for C/C++/Objective' back to GCC 4.2, it worked.
在我将“构建设置”->“为 C/C++/Objective 编译”更改回 GCC 4.2 后,它起作用了。
Apple Radar 10278815 reported, and LLVM Bug 11126reported. Hopefully Apple will fix it before Xcode 5.
Apple Radar 10278815 报告,LLVM Bug 11126报告。希望 Apple 在 Xcode 5 之前修复它。
回答by apouche
A wild guess is a special character that appeared on your line, you were probably using some special character encoding in XCode 3 and opening the file in XCode 4 triggers this error.
一个疯狂的猜测是出现在您的行上的特殊字符,您可能在 XCode 3 中使用了一些特殊字符编码,而在 XCode 4 中打开文件会触发此错误。
To see if this answer is correct I would recommend you cat
or vim
the file in your terminal and see if some wild characters are located at this specific line.
要查看此答案是否正确,我会推荐您cat
或vim
终端中的文件,并查看此特定行是否有一些通配符。
Let us know if this works
让我们知道这是否有效