Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include error issue #13322

Open
namanagrawal007 opened this issue Feb 28, 2025 · 2 comments
Open

include error issue #13322

namanagrawal007 opened this issue Feb 28, 2025 · 2 comments
Assignees
Labels
Language Service more info needed The issue report is not actionable in its current state

Comments

@namanagrawal007
Copy link

namanagrawal007 commented Feb 28, 2025

Image

Title:
📌 #include errors in C++ despite correct settings in VS Code (MSYS2 GCC)

Description:
I am experiencing persistent #include errors in VS Code with the C/C++ extension, even though my code compiles fine. IntelliSense is failing to detect standard headers, and squiggles appear under #include and other system headers.

VS Code Info:
VS Code Version: 1.97.2 (User Setup)
C/C++ Extension Version: 1.23.6
OS: Windows 11 Home Single Language (Version 24H2)
Compiler: MSYS2 GCC (C:\msys64\ucrt64\bin\gcc.exe -v output below)

Error Message:
#include errors detected. Please update your includePath.

Steps to Reproduce:
Open a C++ file in VS Code.
Add #include (or any standard library).
The editor shows an #include error, even though the file compiles fine.
What I Have Tried (None Worked):
✅ Installed/Reinstalled the C/C++ Extension
✅ Verified compilerPath in c_cpp_properties.json
✅ Manually added includePath for MSYS2 GCC
✅ Used "C_Cpp.default.includePath" in VS Code Settings
✅ Reset IntelliSense Cache (C/C++: Reset IntelliSense Database)
✅ Ran Extension Bisect (No conflicting extensions found)
✅ Fully reinstalled VS Code and deleted Code folder in AppData
✅ Issue persists with older versions of the C/C++ extension

Expected Behavior:
VS Code should correctly detect #include paths for IntelliSense without showing errors.

Configuration and Logs

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\msys64\\ucrt64\\bin\\gcc.exe",
            "intelliSenseMode": "${default}"
        }
    ],
    "version": 4
}

Other Extensions

i have installed only two extensions

  1. C/C++ Extension Pack(Microsoft)
  2. Coderunner

Additional context

Running gcc.exe -v confirms that the include paths exist.
Downgrading to older versions of the C/C++ extension (e.g., 1.23.4, 1.23.3) does not resolve the issue.

@Colengms
Copy link
Contributor

Colengms commented Mar 1, 2025

Hi @namanagrawal007 . I'm not able reproduce this with a simple example. Could you set the setting "C_Cpp.loggingLevel": "Debug", and provide the contents of the C/C++ output channel from launch until the repro? That should give us some clues as to what's happening. Do you have any other C/C++ related VS Code settings set?

@Colengms Colengms self-assigned this Mar 1, 2025
@Colengms Colengms added Language Service more info needed The issue report is not actionable in its current state labels Mar 1, 2025
@namanagrawal007
Copy link
Author

Hi, I enabled "C_Cpp.loggingLevel": "Debug" and here are the logs from the C/C++ Output Channel:

loggingLevel: Debug
LSP: (received) cpptools/initialize (id: 1)
LSP: (invoked) cpptools/initialize (id: 1)
cpptools version (TypeScript): 1.23.6
cpptools version (native): 1.23.6.0
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
LSP: Sending response (id: 1)
LSP: (received - deferred) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/queryCompilerDefaults (id: 2)
LSP: (invoked) cpptools/queryCompilerDefaults (id: 2)
Querying compiler for default C++ language standard using command line: C:\msys64\ucrt64\bin\gcc.exe -x c++ -E -dM nul
Querying compiler for default C++ language standard using command line: C:\msys64\ucrt64\bin\gcc.exe -x c++ -E -dM /dev/null
Detected language standard version: c++98
Querying compiler's default target using command line: "C:\msys64\ucrt64\bin\gcc.exe" -dumpmachine
Compiler returned default target value: x86_64-w64-mingw32
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m32 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -Wp,-v -E -dM -x c nul
Attempting to get defaults from C compiler in "compilerPath" property: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m32 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -Wp,-v -E -dM -x c nul
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul
LSP: Message ignored due to no registered handler: $/setTrace
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul
Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
LSP: Sending response (id: 2)
LSP: (received) cpptools/queryCompilerDefaults (id: 3)
LSP: (invoked) cpptools/queryCompilerDefaults (id: 3)
LSP: (received) cpptools/didChangeCppProperties (id: 4)
LSP: (received) cpptools/didChangeSettings
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m32 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -Wp,-v -E -dM -x c nul
Attempting to get defaults from C compiler in "compilerPath" property: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m32 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -Wp,-v -E -dM -x c nul
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul
Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler info database not connected - skipping load.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
LSP: Sending response (id: 3)
LSP: (invoked) cpptools/didChangeCppProperties (id: 4)
Code browsing service initialized
Populating file name cache...
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m64 -Wp,-v -E -dM -x c nul
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul
Done populating filename cache. Elapsed time: 2 ms
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m32 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul
Attempting to get defaults from C compiler in "compilerPath" property: 'C:\msys64\ucrt64\bin\gcc.exe'
Attempting to get defaults from C++ compiler in "compilerPath" property: 'C:\msys64\ucrt64\bin\gcc.exe'
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\msys64\ucrt64\bin\gcc.exe'
Unable to configure for compiler cl.exe.
Attempting to get defaults from compiler found on the machine: 'C:\msys64\ucrt64\bin\gcc.exe'
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m64 -Wp,-v -E -dM -x c++ nul
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -m32 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -m32 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c++98 -Wp,-v -E -dM -x c++ nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: C:\msys64\ucrt64\bin\gcc.exe -std=c17 -Wp,-v -E -dM -x c nul
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
No suitable compiler found. Please set the "compilerPath" in c_cpp_properties.json.
Folder: C:\USERS\NAMAN AGRAWAL\ONEDRIVE\DESKTOP\PRACTISE\ will be indexed
LSP: (queued) cpptools/didChangeVisibleTextEditors
LSP: Sending response (id: 4)
LSP: (invoked) cpptools/didChangeSettings
Discovering files...
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
Enhanced Colorization is enabled.
LSP: (invoked) cpptools/didChangeVisibleTextEditors
Processing folder (recursive): C:\USERS\NAMAN AGRAWAL\ONEDRIVE\DESKTOP\PRACTISE
Discovering files: 1 file(s) processed
0 file(s) removed from database
Done discovering files.
Populating include completion cache.
Parsing remaining files...
Parsing: 0 files(s) processed
Done parsing remaining files.
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) textDocument/didOpen: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp
LSP: (invoked) textDocument/didOpen: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp
LSP: (received) cpptools/getCodeActions: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 5)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 5)
LSP: Sending response (id: 5)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
Intellisense update pending for: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp
LSP: (received) cpptools/didChangeActiveEditor: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp
LSP: (invoked) cpptools/didChangeActiveEditor: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp
LSP: (received) cpptools/getDocumentSymbols: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 6)
LSP: (invoked) cpptools/getDocumentSymbols: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 6)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeTextEditorSelection
LSP: Sending response (id: 6)
IntelliSense update scheduled and TU acquisition started for: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp
Resolving recursive includes...
Done resolving recursive includes.
LSP: (received) cpptools/getCodeActions: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 7)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 7)
LSP: Sending response (id: 7)
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 8)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 8)
LSP: Sending response (id: 8)
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 9)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 9)
LSP: Sending response (id: 9)
sending compilation args for C:\Users\Naman Agrawal\OneDrive\Desktop\practise\p.cpp
include: C:\USERS\NAMAN AGRAWAL\ONEDRIVE\DESKTOP\PRACTISE
define: _DEBUG
define: UNICODE
define: _UNICODE
stdver: ms_c++17
intelliSenseMode: windows-msvc-x64
Error squiggles will be disabled in: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp
Update IntelliSense time (sec): 0.555
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 10)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 10)
LSP: Sending response (id: 10)
LSP: (received) cpptools/getCodeActions: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 11)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 11)
LSP: Sending response (id: 11)
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 12)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 12)
LSP: Sending response (id: 12)
LSP: (received) cpptools/hover: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 13)
LSP: (invoked) cpptools/hover: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 13)
LSP: Sending response (id: 13)
LSP: (received) cpptools/hover: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 14)
LSP: (invoked) cpptools/hover: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 14)
LSP: Sending response (id: 14)
LSP: (received) cpptools/getCodeActions: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 15)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 15)
LSP: Sending response (id: 15)
LSP: (received) cpptools/hover: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 16)
LSP: (invoked) cpptools/hover: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 16)
LSP: Sending response (id: 16)
LSP: (received) cpptools/getCodeActions: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 17)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 17)
LSP: Sending response (id: 17)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/pauseCodeAnalysis
LSP: (invoked) cpptools/pauseCodeAnalysis
LSP: (received) cpptools/resumeCodeAnalysis
LSP: (invoked) cpptools/resumeCodeAnalysis
LSP: (received) cpptools/getCodeActions: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 18)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/Users/Naman%20Agrawal/OneDrive/Desktop/practise/p.cpp (id: 18)
LSP: Sending response (id: 18)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors

Additionally, my current C/C++ related settings in settings.json are:

{
    "C_Cpp.default.compilerPath": "C:\\msys64\\ucrt64\\bin\\gcc.exe",
    "C_Cpp.default.intelliSenseMode": "${default}",
    "C_Cpp.default.includePath": [
        "${workspaceFolder}/**"
    ],
    "C_Cpp.loggingLevel": "Debug"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language Service more info needed The issue report is not actionable in its current state
Projects
Status: No status
Development

No branches or pull requests

2 participants