cubuntuvisual-studio-codeincludeinclude-path

VSCode can't recognise includes


I'm using a Ubuntu machine for a couple years now, and everything worked. For the past few months however, VSCode started acting up, refusing to recognize includes, Not only do the non-native includes like <bits/stdc++.h> not work, but also I can't include other files that are in the same directory. Like this: VScode display

It's not to much of a problem, because I don't compile or debug anything inside VSCode IDE, it's just bothersome because the persistent error on the includes prevents other errors in the code from getting squigly lines and doesn't allow me to autocomplete.

I've never had this problem before, I don't recall changing any settings, and I've even tried "sudo apt remove code" to uninstall and reinstall, and it didn't fix it. Do you have any explanation or fix for this, besides finally switching to a text editor that doesn't suck?

PS: I don't want to have to open every folder i want to code in on VSCode, so creating ".vscode" dir and editing "c_cpp_properties.json" to include file path would not be a solution.

I've tried removing and reinstalling VSCode via "apt", I don't believe it fully removed, since when i reinstalled the extensions still existed.


Solution

  • => Verify the C/C++ Extension: Make sure you have Microsoft C/C++ extensions are installed and up to date. Go to Extensions and search for "C++", make sure you have "C/C++" installed by Microsoft.

    =>Set the Compiler Path If the compiler path is not configured properly, VSCode may not know where to look for standard library titles.

    **

    /usr/bin/gcc

    **