BOOL, bool, Boolean in Objective C, objectivebool
I,
1. Different Types
BOOL is int type
Bool is Boolean
2. Different Lengths
Bool has only one byte
The BOOL length depends on the actual environment. Generally, it can be regarded as 4 bytes.
3. Different values
Bool values: false and true, which are the difference between 0 and 1.
BOOL values: FALSE and TRUE, which are the difference between 0 and non-0.
II:
Bool is a standard C ++ data type, which can be set to true or false. Occupies one byte separately,
If multiple bool objects are listed together, each bit may be occupied, depending on the compiler.
BOOL is the typedef int BOOL defined by Microsoft. Unlike bool, It is a three-value logic,
TRUE/FALSE/ERROR. If the returned value is greater than 0, the integer is TRUE, the value 0 is FALSE, and the value-1 is ERROR.
In Win32 API, many functions with return values of BOOL are three-value logic. For example, GetMessage ().
III:
Differences between large and small BOOL:
1. Different Types
BOOL is int type
Bool is Boolean
2. Different Lengths
Bool has only one byte
The BOOL length depends on the actual environment. Generally, it can be regarded as 4 bytes.
3. Different values
Bool values: false and true, which are the difference between 0 and 1.
BOOL values: FALSE and TRUE, which are the difference between 0 and non-0.
4. Example
Bool x = 3; // alarm
Bool x = 1; // correct
BOOL x = 3; // correct
BOOL x = 3.3; // alert
Note: windows defines basic variables for compatibility issues.
Typedef unsigned long DWORD;
Typedef int BOOL;
Typedef unsigned char BYTE;
Typedef unsigned short WORD;
Typedef float FLOAT;
Typedef FLOAT * PFLOAT;
Typedef BOOL near * PBOOL;
Typedef BOOL far * LPBOOL;
Typedef BYTE near * PBYTE;
Typedef BYTE far * LPBYTE;
Typedef int near * PINT;
Typedef int far * LPINT;
Name |
Typedef |
Header |
True Value |
False Value |
BOOL |
Signed char |
Objc. h |
YES |
NO |
Bool |
_ Bool(Int) |
Stdbool. h |
True |
False |
Boolean |
Unsigned char |
MacTypes. h |
TRUE |
FALSE |
NSNumber |
_ NSCFBoolean |
Foundation. h |
@ (YES) |
@ (NO) |
CFBooleanRef |
Struct |
CoreFoundation. h |