![]() |
| | #1 |
| Registered User Join Date: Apr 2008
Posts: 5
| bool typedef and binary compatibility Code: /* Boolean type, assignment (but not necessarily binary) compatible with
* C++ bool */
typedef enum {sox_false, sox_true} sox_bool;
Does this mean that the C++ built-in bool usually compiles to a size of 1 byte whereas a C bool defined using and enumerated type is essentially an int and therefore usually 2 or 4 bytes in size? |
| BattlePanic is offline | |
| | #2 |
| and the hat of sweating Join Date: Aug 2007 Location: Toronto, ON
Posts: 3,120
| |
| cpjust is offline | |
| | #3 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Yes, and enum's aren't necessarily binary compatible between different compilers, e.g. one compiler may decide to use short int (2 bytes), and another compiler uses a standard or long int (4 bytes). -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
![]() |
| Tags |
| enum bool typedef binary |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Polynomials and ADT's | Emeighty | C++ Programming | 20 | 08-19-2008 08:32 AM |
| macros and size of | -EquinoX- | C Programming | 6 | 03-29-2008 10:55 AM |
| binary search tree help | noob2c | C++ Programming | 6 | 11-09-2003 02:51 PM |
| Headers that use each other | nickname_changed | C++ Programming | 7 | 10-03-2003 04:25 AM |
| BST/Red and Black Tree | ghettoman | C++ Programming | 0 | 10-24-2001 10:45 PM |