Click here to Skip to main content
15,885,782 members
Articles / Programming Languages / VC++
Tip/Trick

Visual Studio Intellisense is Not Working? Try This.

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
2 Apr 2021CPOL2 min read 16.9K   4   2
A couple of fixes when your Visual Studio Intellisense becomes buggy
Is your Intellisense behaving strange when project builds fine? Here are some tips that may help you. Edit: added one solution if project does not build successfully.

IDE: Microsoft Visual C++ 2019

Introduction

Have you ever had a project that would build fine, but VS Intellisense showed a bunch of errors which shouldn't be there? Or maybe you could not Go to Definition while it had a proper definition?
I want to share with you fixes and observations that did help me.

Be aware that these tips do not guarantee that your problem will be fixed, but if they do help, I will be very happy. about it!

Intellisense symptoms i managed to fix

  • Project builds and works fine with red wavy lines all over the place.
  • Selecting a declaration and trying Go to Definition but... (choose one of those: nothing happens, shows error Definition not found, jumps to completely wrong file/line, etc.).
  • Rename a symbol might claim that the symbol does not exist or there is a symbol ambiguity.
  • Intellisense does not work for the whole file.
  • Compiler error: HWND (possibly any other WinAPI type) is not a type name.

Solution

  1. The most important thing - start from scratch. Try to rewrite it in a 100% pure, working solution. Remove lines of code until the problem is gone. That's how i discovered the solution #6.

  2. So, the file has some problems. Does it belong to any project/solution? If yes, then ensure that the project/solution exists. But this existing is not enough for Intellisense - the project/solution must be in working condition (it must build without errors).
        In my case intellisense ignored the file that was a part of a broken solution! I couldn't even open the solution (.sln file) because one of its project was using property sheet... that i deleted. So i removed the reference to that unexisting property sheet and the problem was fixed.
  3. Go to Project -> _your_project_name Properties -> C/C++ -> General. To your right, there is a value Additional Include Directories. Make sure that all directories exist, otherwise VS Intellisense may complain at every #include statement.
  4. You may heard of deleting .vs folder that sits in your Solution directory. It did help me in most cases with Go to Definition and Rename a symbol.
  5. It is a terrible workaround, but it may fix the behavior of VS Intellisense. So in my case, VS Intellisense just hates static symbols that are used outside of classes,structures and local scopes. Whenever I start to use static global functions/variables, I forget about VS Intellisense existence because it becomes so buggy that I cannot do anything about it.
  6. Do all your functions have a name?
    If you are working with WinAPI those 3 lines will never compile:
    #include <windows.h>
    HWND mainWnd; // compiler error E0757: variable "HWND" is not a type name
    int (HWND); // a function without a name and with HWND as a parameter? WinAPI won't let you compile your project and Intellisense won't tell you what's wrong.

History

  • 6th February, 2021: Article created
  • 3rd June, 2021: Added 1st and 6th solution

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Praiseuseful tip Pin
Southmountain24-Apr-21 10:05
Southmountain24-Apr-21 10:05 
GeneralRe: useful tip Pin
Avtem11-May-21 3:48
Avtem11-May-21 3:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.