我经常发现让 Visual Studio 找到我的标题时遇到问题,我想我可能终于找到了原因:似乎 Visual Studio 不理解项目配置中的多个相对目录,例如:
当该目录确实存在时。
我的问题是:有人可以确认是这种情况吗?如果是这样,他们是否有理由这样做?这是一个错误还是故意的?
我经常发现让 Visual Studio 找到我的标题时遇到问题,我想我可能终于找到了原因:似乎 Visual Studio 不理解项目配置中的多个相对目录,例如:
当该目录确实存在时。
我的问题是:有人可以确认是这种情况吗?如果是这样,他们是否有理由这样做?这是一个错误还是故意的?
Posting as an answer as I can't really fit this into a comment although its a bit frowned upon...
The easiest way to debug this is to run Process Monitor from here, and add a filter to only show access to your file name. I made an example c++ project which tried to load a non existant header #include "Bobby.h"
and then added the following filter to Process Monitor:
Path Contains Bobby.h Include
Then I ran the build and got the following output:
CreateFile C:\Users\MyUserName\Documents\Visual Studio 2012\Projects\ConsoleApplication2\ConsoleApplication2\Bobby.h NAME NOT FOUND
CreateFile C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\Bobby.h NAME NOT FOUND
CreateFile C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\Bobby.h NAME NOT FOUND
CreateFile C:\Program Files (x86)\Windows Kits\8.0\Include\um\Bobby.h NAME NOT FOUND
CreateFile C:\Program Files (x86)\Windows Kits\8.0\Include\shared\Bobby.h NAME NOT FOUND
CreateFile C:\Program Files (x86)\Windows Kits\8.0\Include\WinRT\Bobby.h NAME NOT FOUND
From this output you can easily see where the compiler searched for the header file - It may be good enough to help you understand why it didn't find it.
HTH