Reputation: 842
In my project I have a main cpp file and any other files are excluded from the build and I include them from the main cpp file to create one translation unit. This worked perfectly in VS 2013 however I am having issues in 2015 where any cpp files that are not included in the build display types defined in other cpp files with red errors. The project builds fine and I can F12 to the type definitions, but the types do not appear in intellisense and are displayed as errors.
Does anyone know if this is a known issue or can any else replicate it - or is it something specific to my setup?
For example I have main.cpp
struct Foo
{
int Bar;
};
#include "Test.cpp"
int main()
{
Foo x = Test();
return 0;
}
And Test.cpp which is exclude from the build using VS UI.
Foo Test()
{
Foo x;
x.Bar = 2;
return x;
}
This builds but intellisense won't display Foo from Test.cpp and will display red errors under Foo.
Upvotes: 3
Views: 1518
Reputation: 9317
I can replicate your issue in Visual Studio 2015.
Excluding the files from build isn't going to do what you want here. Since you're effectively using those .cpp
files as header files, you need to indicate that to IntelliSense.
In the properties of those files, revert the Excluded From Build
setting to <inherit from parent or project defaults>
and set Item Type
to C/C++ header
(remember to have All Configurations
and All Platforms
selected at the top).
At this point, the squiggles are still there. Save and close the solution, and then delete the solution's .sdf
file (it will be recreated automatically). Reopen the solution and enjoy the lack of squiggles.
Upvotes: 3