Take the 2-minute tour ×

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.

share|improve this question
Which line of code is triggering this error? Which BOOL did you right-click on in that line? –  BoltClock Oct 13 '11 at 8:35
@BoltClock - "did you right-click on in that line" - Of course I did :) –  noloader Oct 13 '11 at 8:38
Were you still getting the error after including objc.h? Your question is a little ambiguous on that point. –  JeremyP Oct 13 '11 at 8:40
@JeremyP - OK, I bite. Why would I ask the question if I had already fixed the problem? Forgive my snippiness - Apple bricked my iPod tonight too. –  noloader Oct 13 '11 at 8:46
@noloader: The question could have been read as "I got it working by including objc.h but is there a better solution" –  JeremyP Oct 13 '11 at 11:14
show 1 more comment

2 Answers

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 or vim the file in your terminal and see if some wild characters are located at this specific line.

Let us know if this works

share|improve this answer
@apouche - Under emacs, it looks like all the characters are 8 bit clean. –  noloader Oct 13 '11 at 9:02
(an earlier version of) clang barfed when it encountered a header with a BOM. took hours to find it, and i had to locate the issue by sending it through a trunk build of clang. –  justin Oct 13 '11 at 9:02
@apouche - Under HexFiend, all the characters on the offending line are 8 bit clean (7 bit ASCII). –  noloader Oct 13 '11 at 9:24
HexFiending was a good idea, you problem seems tricker than it appeared at first. Keep us posted if you find the solution –  apouche Oct 13 '11 at 9:33
@Justin - you should have answered - it was a broken LLVM 3.0 front end. –  noloader Oct 13 '11 at 9:59
show 2 more comments
up vote 2 down vote accepted

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.

share|improve this answer
add comment

Your Answer


