Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > bool vs BOOL

bool vs BOOL
Thread Tools
arcticmac
Dedicated MacNNer
Join Date: Apr 2004
Status: Offline
Reply With Quote
Nov 19, 2005, 07:20 PM
 
just had to ask... is there a difference between bool and BOOL? both seem to get highlighted by the syntax highlighter in XCode.
     
Wevah
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Nov 19, 2005, 07:57 PM
 
Depends. "bool" might not be defined for straight Objective-C, whereas "BOOL" might not be defined for C++ (though I'm not totally sure about what's defined where, except that BOOL is Obj-C).

It's best to use the one that's "right" for the context, for readability; the same extends to nil vs. NULL for null Obj-C object pointers vs. general C NULLs (etc.).

(At least, this is my best explaination of it (being groggy and all); someone else probably has a better or additional explanation.)
[Wevah setPostCount:[Wevah postCount] + 1];
     
arcticmac  (op)
Dedicated MacNNer
Join Date: Apr 2004
Status: Offline
Reply With Quote
Nov 20, 2005, 12:48 AM
 
sounds good for now... just use BOOL, and don't worry. OK.
     
smitty825
Forum Regular
Join Date: Sep 2003
Location: San Diego
Status: Offline
Reply With Quote
Nov 20, 2005, 02:10 AM
 
As Wevah said, bool is defined in Obj-C, but not is standard c or c++. In objc.h, BOOL is defined as a "signed char", while a bool in C/C++ standard doesn't have to be any specific size. A BOOl YES value is defined as 1 and a BOOL NO value is defined as 0, which maps well to the true/false in the "bool" world.

Granted as Wevah said...it's best to use BOOL for Obj-C stuff, and bool for C/C++ stuff just for clarity!
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 07:40 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,