The vc compiler automatically disambiguates the location of stdafx.h when you
#include "stdafx.h"
, using a set of defined rules (see MSDN for specifics), BUT IntelliSense does not. Therefore even when a piece of code compiles successfully, IntelliSense will not work correctly because it doesn't use the same logic as the compiler. If you specify the exact location of the file, as in
#include "..\\stdafx.h"
, IntelliSense will now work right, but the compiler will call an error since it's looking for
#include "stdafx.h"
and not any other variant (bad string compare logic).
What makes this worse? Microsoft claims this is by design (
http://connect.microsoft.com/VisualStudio/feedback/details/533605/stdafx-h-cant-be-parsed-with-intellisense-squiggles-mechanism[
^]).
There are a couple of ways to get around this "feature". Do a double include since the header guard should prevent problems:
#include "stdafx.h"
#include "..\\stdafx.h"
Or include the location of stdafx.h as one of the project's default directories. A less preferable method in my case since I'm developing the code to eventually transfer to a larger project.