Visual Studio expression containing a term named "by" cannot be evaluated in the watch window
- by Andrei Pana
Consider my C++ code below:
int _tmain(int argc, _TCHAR* argv[])
{
int by = 10;
printf("%d\n", by);
int bx = 20;
printf("%d\n", (by + bx));
return 0;
}
which works fine. The funny thing is with the "by" variable. If I try to add a watch for a simple expression that contains by, the result will be CXX0030: Error: expression cannot be evaluated.
For example, on a breakpoint on return 0, if I add the following watches I get the results mentioned:
by : 10
bx : 20
by + 5 : CXX0030: Error: expression cannot be evaluated
bx + 5 : 25
by + bx : CXX0030: Error: expression cannot be evaluated
(by) + bx : 30
by + (bx) : CXX0030: Error: expression cannot be evaluated
bx + (by) : CXX0014: Error: missing operrand
This happens on VS2010, VS2008 on multiple computers.
So, more out of curiosity, what is happening with "by"? Is it some kind of strange operator? Why doesn't bx get the same treatment?
(I've tried google on this but it is quite difficult to get some relevant hits with terms like "by")