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

凌辉 丁 0 Reputation points
2024-06-27T05:58:12.2966667+00:00

屏幕截图 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
C++
C++
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
    2024-06-27T06:19:31.18+00:00

    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
    2024-06-27T10:44:05.1733333+00:00

    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

    WithFilter

    Without Filters file

    WithoutFilter

    0 comments No comments