Xcode 4:“错误:未知类型名称”BOOL“;您的意思是“BOOL”吗?
我有一个在 Xcode 3.2.x 下运行良好的项目。在 Xcode 4.2 下,编译时出现以下错误:
"error: unknown type name 'BOOL'; did you mean 'BOOL'?"
我可以右键单击有问题的 BOOL
,Xcode 将跳转到 Apple 的定义。 BOOL
是在
中定义的,因此我将其包含在我的源文件中(尽管事实上我正在使用 UIKit.h 的预编译标头)和 Foundation.h)。仍然没有喜悦 - 编译错误仍然存在。
任何关于 Xcode 4 解决方案的想法将不胜感激。 Google 提供 0 次点击。
编辑:添加了有问题的代码以消除任何歧义。
// 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;
}
编辑:在查看了 Emacs 和 HexFiend 下的源代码中的非法字符并没有找到任何字符(源代码是 8 位干净的)之后,我倾向于相信这是由于 Apple 方面的某种错误造成的。
I have a project which worked great under Xcode 3.2.x. Under Xcode 4.2, I'm getting the following error when compiling:
"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.
Any ideas for Xcode 4 work arounds would be appreciated. Google is offering 0 hits.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个疯狂的猜测是您的行中出现了一个特殊字符,您可能在 XCode 3 中使用了一些特殊字符编码,并且在 XCode 4 中打开文件会触发此错误。
要查看这个答案是否正确,我建议您在终端中
cat
或vim
文件,看看是否有一些通配符位于该特定行。让我们知道这是否有效
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.
To see if this answer is correct I would recommend you
cat
orvim
the file in your terminal and see if some wild characters are located at this specific line.Let us know if this works
这是苹果公司的软件损坏了。
Apple 忽略了我的 3.2.6 项目设置并决定使用 LLVM 3.0 套件而不是 GCC 4.2。以前(在 Xcode 3.2.6 下),由于我大量使用 GCC 警告和标志,我专门将项目设置为使用 GCC。
在我更改“构建设置”后 -> “编译 C/C++/目标”回到 GCC 4.2,它起作用了。
Apple Radar 10278815 已报告,LLVM Bug 11126 已报告。希望苹果能在 Xcode 5 之前修复它。
It was broken Apple software.
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.
After I changed 'Build Settings' -> 'Compile for C/C++/Objective' back to GCC 4.2, it worked.
Apple Radar 10278815 reported, and LLVM Bug 11126 reported. Hopefully Apple will fix it before Xcode 5.