| | |
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
Views: 1636 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





