Thanks! /useenv also solved this problem for me. VS Community Edition 2017 (15.5.7) on Windows 10. Like the OP, I'm only using it for debugging (Sublime for editing).
Before I was running VS like this:
Run the shortcut on my desktop that points to:
| C:\Windows\System32\cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"
|
In the resulting terminal, "cd" to the dir with my built exe file, and type:
| devenv win32_handmade.exe
|
I could then right click on "win32_handmade" in solution explorer, select Debug > Step into new instance, and it would bring up my source code in VS. But when I would right click on a header file include statement and click "Open document <filename...>", I would get the same error as the OP.
Running VS with this command instead makes it work:
| devenv win32_handmade.exe /useenv
|
Still don't really understand why, but thanks mrmixer!