typedef enum
what's wrong with this line when I try to compile in C++?? The src code was originally in C. It gets an expected identifier error with my c++ compiler
typedef enum {false, true} bool;
number87
Junior Poster in Training
83 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
so C doesnt have bool defined that's why they need to define it like that?
number87
Junior Poster in Training
83 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Yes. bool was added to the C++ specification in a later release.
However bool is a loose specification within Visual Studio. It allows you to assign other values then bool true false. If I'm converting a program over to the current compiler I'll use something like:
typedef enum
{
bfalse = 0,
btrue = 1
} tbool; // Boolean!
#define bool tbool
#define false bfalse
#define true btrue
This is actually strong typechecking so easier to find mismatched boolean assignments as they'll cause compiler errors. Once found comment out and use the now standard bool. The macros override the compiler declarations.
wildgoose
Practically a Posting Shark
896 posts since Jun 2009
Reputation Points: 546
Solved Threads: 99