Reputation: 331
I'm working with a rather old codebase, and it's all pre-C99. Therefore, there is no bool
type, but rather a BOOLEAN
enum. I'm a young gun, so I like VS 2010, but it's not playing particularly well with the old codebase. I guess it's using MSVC2010 to do its in-line error highlighting, and I'm also guessing MSVC2010 conforms to the C99 standard. I could be wrong about this, but in any case, it highlights "errors" when I assign BOOLEAN variables with a boolean expression. I'll give a simple example:
typedef enum boolean_tag {FALSE, TRUE} BOOLEAN;
BOOLEAN test = FALSE;
test = 1 == 1;
In the VS2010 editor, the =
would be error-highlighted, and on mouseover will note that a value of type bool
cannot be assigned to an entity of type BOOLEAN
. Since pre-C99 has no concept of a bool
, this should simply be an assignment of enum values, and therefore not an error.
So, my question is: is there a way to tell VS2010 to use pre-C99 syntax/error-checking? Or alternatively, and this is a stretch, have it use another compiler altogether for these functions?
Thanks.
EDIT: Corrected MSVC2010 assumption
Upvotes: 0
Views: 343
Reputation: 215245
Some things to consider:
1 == 1
evaluates to true
of type bool
.1 == 1
evaluates to the value 1
of type int
.Visual Studio complains because you are trying to store a bool in an enum, which is not fine in C++, a language with somewhat strong typing. In the C language there are no such restrictions.
The answer to your question is: you are getting these problems because you try to compile a C program in a compiler for another programming language.
Upvotes: 3