Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mspman

macrumors regular
Original poster
Jun 7, 2007
236
76
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??
 
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.
 
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:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.