VS can't find the header file located at obvious position

凌辉 丁 0 Reputation points

屏幕截图 2024-06-27 135104

As you can see, I placed game.h in the header file filter and hecate.cpp in the source file filter. The hecate.cpp file includes game.h, but it shows an error indicating that the game.h file is not found. How can Visual Studio make such an obvious mistake? I thought that since you classify files into header and source filters, it should work automatically.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,869 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,628 questions
{count} votes

2 answers

Sort by: Most helpful
  1. 凌辉 丁 0 Reputation points

    I find that I can only copy file and organize them from explorer. Afterward, I include those file into the project. Actually, Visual Studio will parse the header file automatically.

    0 comments No comments

  2. RLWA32 43,046 Reputation points

    The filters file used with a C++ project is only used by the Visual Studio IDE for organizing and displaying files in the Solution Explorer. It has no bearing on how the compiler searches for files specified with the #include directive.

    For example, the same C++ project build successfully with or without a filters file. You can see the difference in the displayed solution explorer panes.

    With filters file


    Without Filters file


    0 comments No comments