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;

bool, true, false are already keyword in C++. you don't need to define enum for it.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.