ObamaRules98
ObamaRules98

Reputation: 15

VSCode showing command-line error: invalid number: 2 0000 on every C/C++ program, code compiles normally

I'm having some trouble with using VSCode for C/C++ development. Although all my programs compile just fine, the extension pack for C/C++ keeps showing me the following error at the start of every single one of my files:

command-line error: invalid number: 2 0000

Originally I thought that this may have been a problem with just my laptop, but after downloading VSCode and setting it up for C development in another computer, the same issue arose again.

I've tried disabling the extension pack, which removes the issue, but when I enable it it shows me the same error again. Reinstalling the extension also did not work, even after I deleted all of the files associated with it. Neither did restarting VSCode, restarting my PC or reinstalling VSCode. I also have not found another question here with a satisfying answer.

Below are some images of the issue:in .cpp filein .c files

Is there a way I can stop this error from appearing, whether it is through fixing the underlying issue or disabling error squiggles for that specific problem? If it's any help, I used the cygnus package to get the gcc and g++ compilers.

Edit: Since people are asking, I'm using windows 10 pro and my gcc and g++ versions are egcs-2.91.57. I downloaded VSCode using the system installer and the only changes I really made to the installation settings from the default ones were adding the options to open folders using VSCode when right clicking. Below is my settings.JSON and the only other relevant settings file I could find(I found it in the extension folder):

settings.JSON:

{
"csharp.semanticHighlighting.enabled": false}

settings.nls.metadata.json:

{
"messages": [
    "Code formatting is using settings from .editorconfig instead of .clang-format. For more information, see the documentation for the 'Default' value of the 'C_Cpp.formatting' setting."
],
"keys": [
    {
        "key": "editorconfig.default.behavior",
        "comment": [
            "Single-quotes are used here, as this message is displayed in a context that does not render markdown. Do not change them to back-ticks."
        ]
    }
],
"filePath": "src\\LanguageServer\\settings"

}

Once again, all I did was download the necessary tools using cygnus(specifically cygwin), download VSCode using the system installer, and install the C/C++ extension pack. I have the same issue in 2 systems.

Upvotes: 0

Views: 4071

Answers (2)

Foad S. Farimani
Foad S. Farimani

Reputation: 14026

I have installed MSYS2 through the Chocolatey package manager on Windows, and then installed the latest version of the GCC Mingw-w64 compiler:

pacman -S mingw64/mingw-w64-x86_64-gcc

then create a .vscode folder in the root of your project folder. Then create the c_cpp_properties.json file with the below content:

{
    "configurations": [
      {
        "name": "mingw64 GCC",
        "compilerPath": "C:\\tools\\msys64\\mingw64\\bin\\gcc.exe",
        "intelliSenseMode": "windows-gcc-x64"
      }
    ],
    "version": 4
  }

Upvotes: 1

ObamaRules98
ObamaRules98

Reputation: 15

Update: I fixed the issue by unistalling Cygwin and installing the necessary tools using msys2. Leaving the question open in case someone finds a fix that doesn't require reinstalling the compilers.

Upvotes: 0

Related Questions