Reputation: 5194
I'm working on a project in Visual Studio 2010. My project is not supposed to be limited to Windows, however, one of the files is OS-dependant.
For this reason, I have #include <windows.h>
in only one of the .cpp files. No other file includes this .cpp files. Therefore, logically, the windows.h
header should be invisible to the rest of the solution.
This means that I don't have any name conflicts with declarations in the Windows library in all files but that one .cpp, and my project compiles just fine.
However, IntelliSense keeps on insisting that I have name conflicts. When I press Ctrl+Space
, IntelliSense suggests identifiers from windows.h
. And this is in the scope where windows.h
should be invisible!
Is there a setting I can change to stop this annoying behaviour?
I'm 100% positive that the issue is not with the structure of my solution because if I use an identifier already defined in windows.h
in another part of my project, the compiler does not recognize it and it doesn't compile...but IntelliSense recognizes it!
Upvotes: 0
Views: 183
Reputation: 179981
Since IntelliSense works on a per-project base (.vcproj), not per-solution (.sln), the easy answer is to move the Windows-specific parts to their own project within your solution.
This also helps with porting, as you can more easily replace the Windows-specific parts.
Upvotes: 1
Reputation: 62985
Quoting Andy Rich, a Microsoft employee who works on VC++, from a comment on this blog article: Troubleshooting Tips for IntelliSense Slowness
The browsing database will find all source files that are somehow included in your project, either directly or as a result of other #include directives. This is not configurable, and is necessary in order for the IDE to be able to provide accurate answers.
So unfortunately the answer is no, there's nothing you can do beyond disabling IntelliSense altogether.
Upvotes: 2