Mac BOOL not getting inherited in fresh install of Xcode

mspman

macrumors regular
Original poster
Jun 7, 2007
224
70
Minneapolis, MN
Okay, what am I doing wrong. I just installed Xcode on a friends MBA, and I'm having issues getting the "BOOL" datatype to be recognized. In the simplest of programs, "Hello World!", I'm importing stdio.h, and when I try to declare a BOOL, I get "Use of undeclared identifier BOOL."

What am I missing??
 

Cromulent

macrumors 603
Oct 2, 2006
6,034
35
The Land of Hope and Glory
Okay, what am I doing wrong. I just installed Xcode on a friends MBA, and I'm having issues getting the "BOOL" datatype to be recognized. In the simplest of programs, "Hello World!", I'm importing stdio.h, and when I try to declare a BOOL, I get "Use of undeclared identifier BOOL."

What am I missing??
Sounds like you are writing a C program. BOOL is the Objective-C keyword. If you want to use a boolean in C code you need to either use the keyword bool (if you are happy using the C99 standard) or #define one yourself.
 

Guiyon

macrumors 6502a
Mar 19, 2008
767
1
North Shore, MA
Okay, what am I doing wrong. I just installed Xcode on a friends MBA, and I'm having issues getting the "BOOL" datatype to be recognized. In the simplest of programs, "Hello World!", I'm importing stdio.h, and when I try to declare a BOOL, I get "Use of undeclared identifier BOOL."

What am I missing??
BOOL is not a C type, it is an Objective-C type. If you want to use it, you'll need to import and link the Foundation framework. If you are targeting the C99 standard, then there is a bool datatype (note the capitalization!) and, IIRC, you'll need to include the stdbool.h header to use it (this also defines true and false). You can also just typedef your own.
 
Last edited: