Why does including windows.h cause working code to give compile errors?

  • Thread starter Thread starter Gaminic
  • Start date Start date
G

Gaminic

Guest
Hello,

I'm quite new to programming and I'm guessing the answer to my question will be "Did you forget to X the Y?", after which I'll reply "...what?" after which a step-by-step guide to X'ing the Y will hopefully follow.

Anyway; I have a project I've been working on for quite some time now and everything works just fine. Yesterday, I spent my time making a directory reader in a separate project and when it was done, I copypasted this to my main project. Suddenly, my working code from the day before starts producing compile errors. I quickly discovered that commenting out #include <windows.h> fixed it, but that means I can't use my directory reader, which is a vital part of my project.

The errors seem to focus on a single variable (a vector<vector<int>> called) that's used throughout the program. Strangely, it's not the only variable of that type used and it's not being used in any other way than the similar variables. The errors are mostly:

C2143 "missing ';' before '.'" when calling a vector method (e.g. .clear())
C2059 "syntax error: ')' when the variable is used as a parameter to a function (being the last parameter), syntax error: ',' when it's not the last parameter
C2059 "syntax error : '[' when an element of the 2dimensional vector is accessed.

All these things are being done quite often on similar variables, yet only this variable is giving errors. It's defined at the top of the program (after the includes), it's name is "nodeProximity" and it's passed by reference to every function that uses it under the name "near".

The second set of compile errors takes place in a validation function, which is mostly boolean statements like this one: "check = (check && n1 != next[n2]);"

That line gives a compile error C3493, saying check, next and n2 can't be implicitly captured.

I have no idea why the windows.h header is causing this. Any and all help would be greatly appreciated!

Thanks in advance.

Continue reading...
 
Back
Top