Jordi Vermeulen
Jordi Vermeulen

Reputation: 1198

VS2012 C++ - Prevent Visual Studio from auto-adding includes

Somewhere in my code, I use std::numeric_limits, but I did not #include <limits> (I did #include <vector>, not sure if this matters). This worked fine for me; apparently Visual Studio fixes my mistake for me during compilation. Then, someone else who was working on the same code (with a different IDE) encountered compiler errors because of the missing include. Is there any way to prevent Visual Studio from doing this, to prevent this from happening again?

Thanks!

Upvotes: 0

Views: 233

Answers (1)

Clifford
Clifford

Reputation: 93456

In order to support its own needs, <vector> includes <limits> (possibly indirectly through other nested includes), so it is available after <vector> is included. Open the <vector> header and take a look.

However in a different implementation, this may not be the case, so you cannot rely on it.

Upvotes: 1

Related Questions