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;
8 Years
Discussion Span
Last Post by wildgoose

so C doesnt have bool defined that's why they need to define it like that?


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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.