Visual Studio does not allow me to use specific variable names

I am using Visual Studio 2010 Express. When I use certain variable names, for example, "near", "far", "IN", "OUT", I can not compile: I get syntax errors located after the variable name. Example:

z = 1.0/(far - near); 

Error:

 error C2059: syntax error : ')' 

How to disable this "feature"?

+6
source share
1 answer

far and near were built-in compiler keywords on 16-bit days. They no longer exist, and they no longer have any meaning, but they are still defined as macros in the Windows headers for backward compatibility reasons.

If you do not want them, simply define them (or do not include the Windows headers):

 #undef far #undef near 
+12
source

Source: https://habr.com/ru/post/906507/


All Articles