My compiler (VC++ 6.0 sp6) has apparently gone insane. In certain pieces of code I’m seeing that ‘bool mybool = true;‘ evalutes to and assigns false, and vice versa for true. Changing the true/false keywords to 1/0 makes it work fine. The same code compiles elsewhere fine without changing the true/false keywords.
What could possibly cause this? My first thought was RAM or disk corruption, but that all checked out fine. I’m not far from reformatting my drive and reinstalling everything, but I’m terrified I’d still see the same misbehavior.
Is it even technically possible for a macro or linked-in library somewhere to screw up the meaning of ‘true‘ and ‘false‘?
UPDATE: Mystery solved. An environment variable flag on my machine was set to ‘false’ and the way this was interpolated by some preprocessor code redefined the keyword.
A preprocessor macro could certainly do it, although that would be pretty surprising. One way to check if that is the case would be
Response to comments:
Find a non-header file where you see this behavior, preferably one with few #includes.
In the middle of the list of includes, put the #ifdef #error directives.
if the error trips you know it’s in the first half of includes, if it doesn’t it’s in the second half. Split the half in half and repeat. When you narrow it down to one header, open that header. If that header includes any headers repeat the process for the list of headers it includes. Eventually you should be able to find the #defines . Tedious, I agree.