BOOL vs. bool?

This is a discussion on BOOL vs. bool? within the Windows Programming forums, part of the Platform Specific Boards category; Until recently I've been using BOOL for most of my TRUE | FALSE stuff, awhile back someone told me I'm ...

  1. #1
    Unregistered
    Guest

    BOOL vs. bool?

    Until recently I've been using BOOL for most of my TRUE | FALSE stuff, awhile back someone told me I'm better off using bool, as BOOL in the SDK creates much larger values than I need for just TRUE and FALSE. Any Pros and Cons in using one or the other? Or for that matter any truth in the claim?

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    BOOL is a typdef of an int and is, as such, 32 bits at the moment. It is declared in windows.h.

    >>> Any Pros and Cons in using one or the other?

    Yes, if you use one type when the other is expected you can get errors. Sometimes extremely difficult to find errors.

    I tend to use bool for my own stuff, because it is portable without using typdef's, however, when I'm using API functions, (portability is then not an issue of course), I always use the type expected.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    106
    Well, BOOL TRUE is acually an integer 1. FALSE being 0.
    bool true is just that, true (similar for false) Problems can arise mixing BOOLs and bools together as information can be lost/take a performance hit in the conversion. Usually MSVC compiler picks these problems up as warnings if the warning level is set to 3 or better.

  4. #4
    Unregistered
    Guest
    Sorry adrianxw, must have posted at the same time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. passing params between managed c++ and unmanaged c++
    By cechen in forum C++ Programming
    Replies: 11
    Last Post: 02-03-2009, 08:46 AM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 10:42 PM
  3. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 08:05 AM
  4. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 05:25 AM
  5. Need Help With an RPG Style Game
    By JayDog in forum Game Programming
    Replies: 6
    Last Post: 03-30-2003, 08:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21