| | |
typedef enum
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 77
Reputation:
Solved Threads: 0
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
C++ Syntax (Toggle Plain Text)
typedef enum {false, true} bool;
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:
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.
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:
C++ Syntax (Toggle Plain Text)
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.
Last edited by wildgoose; Aug 12th, 2009 at 3:17 am.
![]() |
Similar Threads
- enum with % (remainder) operator (C++)
- creating array of enum type (C++)
- enum warnings (C++)
- Struct, Function, Enum problem (C)
- Enum type in C++ (C++)
- the type def statement and enum (C++)
Other Threads in the C++ Forum
- Previous Thread: Pointer Function problem
- Next Thread: Access the Class method via the pointer
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





