• Did you order new AirTags? We've opened a dedicated AirTags forum.

mspman

macrumors regular
Original poster
Jun 7, 2007
229
72
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,042
37
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.
 
Comment

Guiyon

macrumors 6502a
Mar 19, 2008
771
4
Cambridge, 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:
Comment
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.