PDA

View Full Version : BOOL not getting inherited in fresh install of Xcode




mspman
Jan 7, 2012, 10:58 AM
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
Jan 7, 2012, 11:02 AM
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
Jan 7, 2012, 11:05 AM
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.

mspman
Jan 7, 2012, 11:19 AM
ARRRRGH!! That's it!

Thanks guys and sorry for the stupid question!