Thread: VC++ & Bool

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    62

    VC++ & Bool

    Hi,
    Sorry I am posting this here as well as the C board but I have to get this straight.

    I am using Visual C++ to write C programs. I have come to need to use bool and I understand that it will not work. Is there a work around.

    Currently when I create a new project I set it up as follows:
    Create new Win32 Application ex. project.cpp
    Change extention on file from project.cpp to project.c
    Next I right click into the files properties and change:
    Precompiled Headers
    |
    |-Create/Use Precompiled Headers

    From Use to Create

    Is that the proper procedure?

  2. #2
    Registered User
    Join Date
    Nov 2007
    Posts
    12
    I don't know about visual C++, but couldn't you just use an int, and set it to 1 or 0 for true or false respectively?

  3. #3
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    boolean should work
    VC sucks.

  4. #4
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    I believe VC (maybe most IDEs too, dont know forsure) use two different compilers when making a program. So if you originally made a .cpp file, it is going to use the c++ compiler vs. the c compiler. There should be an option when you make a new project that states if it's c++ or c.

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    MSVC decides whether to compile as C code or C++ code based on the file extension, though I think there is a project setting to override this.

    In C the classic thing to do it to simply use 'int' and return 1 or 0. Typically TRUE is defined as 1 and FALSE is defined as 0. You may even find that you're including headers that define BOOL for you (which is just int).
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

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, 09:42 PM
  3. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 07:05 AM
  4. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04: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