Thread: "bool" in Visual C++

  1. #1
    Registered User Sharke's Avatar
    Join Date
    Jun 2008
    Location
    NYC
    Posts
    303

    "bool" in Visual C++

    I'm reading a book that says if your compiler doesn't support C99, you can replace

    Code:
    #include <stdbool.h>
    with this:

    Code:
    enum bool {false, true};
    And then, apparently, I can go ahead and have functions that return bool, etc.

    But it doesn't work. Is this book having a laugh with me?

    Visual C++ shows bool as a keyword, but I presume this doesn't matter if I'm compiling as C. Anyway I tried using "boot" instead of "bool" as a test and it still doesn't work.
    Last edited by Sharke; 04-10-2009 at 10:48 PM.

  2. #2
    Registered User Sharke's Avatar
    Join Date
    Jun 2008
    Location
    NYC
    Posts
    303
    OK so upon further experimentation it seems the book should have really said:

    Code:
    typedef enum {false, true} bool;
    Just another error in Prata's C Primer Plus I suppose!

    While we're on the subject, I found a great one in some of his sample code:

    Code:
    while (current != NULL)
    {
        free(current);
        current = current->next;
    }
    This, in the 5th edition of the book!

  3. #3
    Banned ಠ_ಠ's Avatar
    Join Date
    Mar 2009
    Posts
    687
    Quote Originally Posted by Sharke View Post
    Code:
    while (current != NULL)
    {
        free(current);
        current = current->next;
    }
    This, in the 5th edition of the book!
    thanks a lot, there's pop all over my keyboard now, and my nose burns
    ╔╗╔══╦╗
    ║║║╔╗║║
    ║╚╣╚╝║╚╗
    ╚═╩══╩═╝

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM