Search code examples
c++visual-studioincludeintellisense

Visual Studio 2019, no Intellisense with "Show all files"


I have started learning C++ with Visual Studio 2019 and noticed a strange behaviour. When you create an empty project you are represented with "Filter" files. Now if I active "Show All Files" I can create directories. I created the following structure:

/Core/
/Engine/
Main.cpp

Now if I create a "class" it is, by default, created next to Main.cpp. I would then move the Class.h and Class.cpp into /Core/.

Now if I start editing the newly created files I loose Intellisense. If I uncheck "Show All Files" I get it back. Does anyone else have the same problem?

Another question I wanted to ask was about filter files and project folder structure. Should I use the filter files to organize my project or an actual folder structure? I'm slightly confused because of the Intellisense problem, that's why I'm asking.

And if I should create a folder structure, how should I handle includes like this #include "..\..\... \FileUpInTree.h". In Javascript and Webpack you could define "Alias" Directories to eliminate this. I was wondering if something like this exists for Visual Studio aswell. Maybe namespaces?


Solution

  • Now if I start editing the newly created files I loose Intellisense. If I uncheck "Show All Files" I get it back. Does anyone else have the same problem?

    I have faced the same issue as you described and when I migrate a file to another folder under the Show All Files filter, Intellisense does not work, which is really strange. When I didn't migrate the file, Intellisense works well at the default address.

    And I have reported this issue on our DC Forum and you can add any detailed info on that link and also anyone who is interested in this issue will vote it so that it will make Microsoft attach great importance.

    The workaround is that you should uncheck Show All Files and then click it again. After that, Intellisense will turn back and works well.

    Another question I wanted to ask was about filter files and project folder structure. Should I use the filter files to organize my project or an actual folder structure? I'm slightly confused because of the Intellisense problem, that's why I'm asking.

    Actually, when you use the default project type in c++ projects(not click Show All Files), this structure will automatically identify each file in your project and categorize it into its own filtering folder. At this time, the intellisense works perfectly, because subdividing various files will not conflict.

    But in this format, you cannot create folder structure.

    enter image description here

    Besides, using the filter files or the actual folder structure are the same effect. If you use actual project structure in the Windows Explorer, it will be showed under solution explorer(click Show All Files) automatically.

    Suggestion

    As long as you do not want to migrate files at will, you can use Intellisense under this filter.

    Or

    1) create folder structure under Show All Files and then uncheck Show All Files to get Intellisense.

    And if I should create a folder structure, how should I handle includes like this #include "....... \FileUpInTree.h". In Javascript and Webpack you could define "Alias" Directories to eliminate this. I was wondering if something like this exists for Visual Studio aswell. Maybe namespaces?

    I think you do not need to worry about this too much.

    When you want to use the file under the folder structure of the project, you can just use #include"xxx.h" and the Intellisense will automatically grab the header file in the project.

    And if you want to reference a c++ class, you can just use namespace <the c++ class namespace>.

    enter image description here

    enter image description here