including windows.h causes clashing with local variable name

Viewed 868

I am including windows.h in one of my h files (in order to use CaptureStackBackTrace), in a Visual-Studio project. At first I got some compiler errors because of the use of min/max std methods and the macro with same name in windows.h, but this seems to be solved by #define NOMINMAX, as I read in other SO posts. (I say "seems" because I can't be sure till my whole project builds ok again).

The problem is that some local variable names now break the build. The line:

int grp1;

inside a class method, causes the following error:

error C2143: syntax error : missing ';' before 'constant'

while the cpp file compiles ok if I change the variable name to grp1_.

Of course I can just change the variable name, but nevertheless I've got a feeling that I am doing something wrong - am I? Or is this a known issue when including windows.h? Is there any other, more elegant solution other than changing the variable name?

3 Answers
Related