DivijM
DivijM

Reputation: 343

VSCode does not show errors before building

I use VSCode(code editor, not IDE) for C++ with only Microsoft's C++ extension and today I have encountered a problem here. When I write the wrong syntax, the "PROBLEMS" panel does not show errors. It only shows errors on building the code. Earlier that wasn't the case. How do I fix this ?

Before building: enter image description here

After building: enter image description here

enter image description here

Upvotes: 5

Views: 54360

Answers (8)

M. R. M.
M. R. M.

Reputation: 645

I tried Enabling error squiggles as this answer suggested but that did not work for me so I tried the following:

(Note: I'm using Ubuntu 22.04.4 LTS)

  1. Make sure you have a compiler installed

  2. Reinstall c/c++ extension

  3. Open Command Palette and go to
    Welcome: Open Walkthrough... > Getting Started with C++ Development
    and select default compiler and set it as you need
    select default compiler screenshot

  4. After that open your c++ file and if you're getting a blue squiggly error under the #include try this solution:

    sudo apt-get install gcc-multilib g++-multilib
    

Doing all this fixed the issue for me:

enter image description here

Upvotes: 0

ZachHappel
ZachHappel

Reputation: 381

I was having a similar issue with Java, and I was able to resolve it by creating an entirely new directory location for the project and copying the project files from the old to the new — excluding the .vscode folder.

This is not clearly an ideal fix, however it did work for me.

Upvotes: 0

Aleksa Hadzic
Aleksa Hadzic

Reputation: 41

I had this same issue with C# so this is how I ended up here.

Managed to fix it by changing the sln file of the project root directory where:

Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "housesapi", "backend\HouseApi\HouseApi.csproj", "{C0FF5955-650A-4458-A35C-50477850354E}"

was incorrect.

After I pointed it to the proper route everything worked and the errors were shown. Here I used the dev kit for C#, a VS Code extension.

Upvotes: 0

Hrishikesh Kumar
Hrishikesh Kumar

Reputation: 21

It worked in my case by just enabling Error Squiggles.

To do this, Open VS Code, press ctrl+shift+p, then, in the search bar, search for "enable error squiggles" and click on it.

Here is one screenshot of search bar for reference

Upvotes: 2

Neil Nguyen
Neil Nguyen

Reputation: 377

I got that error by Disable error squiggles. If you don't reach that error in my case, don't read anymore.

enter image description here

After ignoring, I got your problem:

enter image description here

To fix this, open settings.json file:

enter image description here

Scroll to the end, then set "C_Cpp.errorSquiggles": from Disabled to Enabled. enter image description here

Upvotes: 25

Yaakov Brill
Yaakov Brill

Reputation: 31

Try and close your current folder and open a different folder. Then come back to your original folder. This worked for me.

Upvotes: 2

Okechukwu Ezekiel
Okechukwu Ezekiel

Reputation: 101

Note: You have to install the extension first: C/C++ IntelliSense, debugging, and code browsing extension

This is because the C/C++ IntelliSense, debugging, and code browsing extension does not know about the current project.

Navigate to View | Command Palette, enter and select C/C++ Build and debug active file: Select Project, and then select the correct project that you want to work with.

This will help you see the problems as you create your code without requiring you to run it.

The extension has to know that it is allowed to continuously check your code.

I hope this helps you in the future with other extensions too...

Upvotes: 3

Alejandro Resendez
Alejandro Resendez

Reputation: 76

After reading the question, and the comments, my understanding is that you want Visual Studio Code to tell you when you make a mistake on the sintax, without having to compile the project.

What could be wrong is your C++ IntelliSense, which is odd because it comes in bundle with the C/C++ extension from Microsoft. The extension itself might be disabled, corrupted during an aborted update, or uninstalled.

Have you tried the good old and helpful uninstall and reinstall the extension? That normally fixes my problems with extensions in Visual Studio and VS Code

Upvotes: 5

Related Questions