-
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?
-
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?
-
boolean should work
VC sucks.
-
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.
-
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).