Thread: Booleans in C

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    42

    Booleans in C

    I need to find a way to do a C++ Booleans in C, the way I've come up with so far is:
    Code:
    typedef enum { false, true } bool;
    bool one = false;
    Which works fine. But, I need to know if this takes up less memory, than a char. Could I possibly take up one bit like 'int bool:1;' in a struct? Is there another less memory usage way?

    Also, I thought I mention, I know there's a bool type in C99. But, I'm developing this for an embedded cpu, which I need to use a special compiler, libraries, the whole bit. I'm trying to save space.
    Last edited by KneeLess; 09-08-2004 at 06:59 PM.
    Sigh, nothing ever works the first try.

    Register Linux User #314127

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Noob getting confused by booleans
    By Nathan the noob in forum C++ Programming
    Replies: 7
    Last Post: 06-27-2008, 03:50 PM
  2. 2d array of booleans
    By eklavya8 in forum C++ Programming
    Replies: 9
    Last Post: 06-27-2008, 02:36 PM
  3. Array of Booleans Represented with 1 Bit
    By Brad0407 in forum C++ Programming
    Replies: 43
    Last Post: 07-08-2007, 01:23 PM
  4. Help plz, Booleans
    By tagman in forum C++ Programming
    Replies: 2
    Last Post: 07-26-2005, 08:30 AM
  5. booleans
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 03-10-2002, 12:01 PM