| | |
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 based beginner bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion count database delete deploy desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project python random read recursion recursive return sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





