IntelliSense misses gcc-style precompiled headers with `compile_commands.json`
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 56/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- devtools
Hướng nghiên cứu
Start by tracing how vscode-cpptools reads compile_commands.json entries for C++ source files and handles GCC's -include and -fpch-preprocess flags; compare that path with the entry producing proj.p/cpp_pch.h.gch. Use the provided commands to reproduce the missing PCH contents in src/main.cpp. Done means IntelliSense recognizes the source header used to produce the .gch and no longer reports its declarations as missing.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
-
OS and Version:
Windows 10 19045.7807 22H2 -
VS Code Version:
1.146.0 -
C/C++ Extension Version:
1.35.6 -
If using SSH remote, specify OS of remote machine:
Debian 13.7 arm64
Bug Summary and Steps to Reproduce
Bug Summary:
When providing a compile_commands.json to vscode-cpptools, IntelliSense can miss including precompiled headers depending on how they're provided.
Steps to reproduce:
Assuming a setup such as this:
├── build
│ ├── compile_commands.json
│ └── proj.p
│ ├── cpp_pch.h.gch
└── src
├── main.cpp
└── pch
└── cpp_pch.h
My build first creates a precompiled header from src/pch/cpp_pch.h, outputting it as build/proj.p/cpp_pch.h.gch. Then, when compiling main, I include it by specifying the proj.p directory as an include directory, and including it with -include cpp_pch.h. Since G++ will automatically look for <pch name>.gch, it finds and uses the already generated one. As src/pch/ is not on the include path, it never tries to include src/pch/cpp_pch.h
This produces a compile_commands.json like so:
[
{
"directory": "/home/user/proj/build",
"command": "g++ -Iproj.p -I. -I.. -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -x c++-header -MD -MQ proj.p/cpp_pch.h.gch -MF proj.p/cpp_pch.h.gch.d -o proj.p/cpp_pch.h.gch -c ../src/pch/cpp_pch.h",
"file": "../src/pch/cpp_pch.h",
"output": "proj.p/cpp_pch.h.gch"
},
{
"directory": "/home/user/proj/build",
"command": "g++ -Iproj.p -I. -I.. -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -fpch-preprocess -include cpp_pch.h -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -MD -MQ proj.p/src_main.cpp.o -MF proj.p/src_main.cpp.o.d -o proj.p/src_main.cpp.o -c ../src/main.cpp",
"file": "../src/main.cpp",
"output": "proj.p/src_main.cpp.o"
}
]
This works fine for compiling and linking, but IntelliSense does not properly notice that the file used as input to generate the cpp_pch.h.gch is what is actually being included via the -include cpp_pch.h. Things that are used in main.cpp get red problem squiggles, because IntelliSense doesn't know anything about what's in cpp_pch.h
Expected behavior:
Ideally vscode-cpp would notice the compile command that generates a *.gch and include the header referenced as an include for sources, especially when the IntelliSense mode is *-gcc-*
Configuration and Logs
## C/C++: Log Diagnostics
-------- Diagnostics - 13/11/2026, 15:26:57
Version: 1.35.6
Current Configuration:
{
"name": "Linux",
"includePath": [
"/home/user/proj/**"
],
"defines": [],
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-arm64",
"compileCommands": [
"/home/user/proj/build/compile_commands.json"
],
"intelliSenseModeIsExplicit": false,
"cStandardIsExplicit": false,
"cppStandardIsExplicit": false,
"mergeConfigurations": false,
"recursiveIncludes": {},
"recursiveIncludesPriorityIsExplicit": false,
"recursiveIncludesOrderIsExplicit": false,
"compilerPathIsExplicit": false,
"configurationProvider": "mesonbuild.mesonbuild",
"browse": {
"limitSymbolsToIncludedHeaders": true
}
}
Modified Settings:
{
"C_Cpp.default.compileCommands": "/home/user/proj/build/compile_commands.json",
"C_Cpp.default.configurationProvider": "mesonbuild.mesonbuild"
}
Additional Tracked Settings:
{
"editorTabSize": 4,
"editorInsertSpaces": false,
"editorAutoClosingBrackets": "languageDefined",
"filesEncoding": "utf8",
"filesAssociations": {},
"filesExclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/.jj": true,
"**/.DS_Store": true,
"**/Thumbs.db": true
},
"filesAutoSaveAfterDelay": false,
"editorInlayHintsEnabled": true,
"editorParameterHintsEnabled": true,
"searchExclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true
},
"workbenchSettingsEditor": "ui"
}
Custom browse configuration:
{
"browsePath": [
""
],
"compilerPath": "g++",
"compilerArgs": []
}
cpptools version (native): 1.35.5.0
Current database path: /home/user/.cache/vscode-cpptools/d6c28b94876ca376959235a45cf94837/.browse.VC.db
Translation Unit Mappings:
[ /home/user/proj/src/main.cpp - source TU]:
[ /home/user/proj/src/pch/cpp_pch.h - source TU]:
Translation Unit Configurations:
[ /home/user/proj/src/main.cpp ]
Process ID: 3242704
Memory Usage: 22 MB
Compiler Path: /usr/bin/g++
Language: C++
Include Paths:
include: /home/user/proj/build/proj.p
include: /home/user/proj/build
include: /home/user/proj
system include: /usr/include/c++/14
system include: /usr/include/aarch64-linux-gnu/c++/14
system include: /usr/include/c++/14/backward
system include: /usr/lib/gcc/aarch64-linux-gnu/14/include
system include: /usr/local/include
system include: /usr/include/aarch64-linux-gnu
system include: /usr/include
Defines:
_GLIBCXX_ASSERTIONS=1
_FILE_OFFSET_BITS=64
Standard Version: c++17
IntelliSense Mode: linux-gcc-arm64
Other Flags:
--g++
--gnu_version=140200
compile_commands.json entry:
directory: /home/user/proj/build
file: /home/user/proj/src/main.cpp
command: g++ -Iproj.p -I. -I.. -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -fpch-preprocess -include cpp_pch.h -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -MD -MQ proj.p/src_main.cpp.o -MF proj.p/src_main.cpp.o.d -o proj.p/src_main.cpp.o -c ../src/main.cpp
output: proj.p/src_main.cpp.o
[ /home/user/proj/src/pch/cpp_pch.h ]
Process ID: 3242926
Memory Usage: 21 MB
Compiler Path: /usr/bin/g++
Language: C++
Include Paths:
include: /home/user/proj/build/proj.p
include: /home/user/proj/build
include: /home/user/proj
system include: /usr/include/c++/14
system include: /usr/include/aarch64-linux-gnu/c++/14
system include: /usr/include/c++/14/backward
system include: /usr/lib/gcc/aarch64-linux-gnu/14/include
system include: /usr/local/include
system include: /usr/include/aarch64-linux-gnu
system include: /usr/include
Defines:
_GLIBCXX_ASSERTIONS=1
_FILE_OFFSET_BITS=64
Standard Version: c++17
IntelliSense Mode: linux-gcc-arm64
Other Flags:
--g++
--gnu_version=140200
compile_commands.json entry:
directory: /home/user/proj/build
file: /home/user/proj/src/pch/cpp_pch.h
command: g++ -Iproj.p -I. -I.. -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -x c++-header -MD -MQ proj.p/cpp_pch.h.gch -MF proj.p/cpp_pch.h.gch.d -o proj.p/cpp_pch.h.gch -c ../src/pch/cpp_pch.h
output: proj.p/cpp_pch.h.gch
Total Memory Usage: 43 MB
Browse Paths from compile_commands.json, from workspace folder: /home/user/proj
/home/user/proj
/usr/include
/usr/lib/gcc/aarch64-linux-gnu/14/include
/usr/local/include
Other Extensions
- vscode-meson, and yes it persists
Additional context
I'm using Meson as a build system which does exactly this for how it handles PCHs, but the issue could happen with any build system, or even just providing the compile commands manually.
Related topics I found while figuring this out, as I had assumed it was a meson (or their extension) thing before realizing the PCH info was actually making it into compile_commands.json: https://github.com/mesonbuild/meson/issues/10590, https://github.com/mesonbuild/vscode-meson/issues/238
- Ngôn ngữ chính
- TypeScript
- Star
- 6.2k
- Fork
- 1.7k
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/vscode-cpptools
-
Missing gcc __builtin_stdc_bit_width/floor/ceil signature makes intellisense wrongly report error 70Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
microsoft/vscode-cpptools#14874 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
microsoft/vscode-cpptools#14872 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
debugger
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
microsoft/vscode-cpptools#14869 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Goto definition (F12) not working with (recursive) includesCó thể đã có người làm @Colengms đã nhận 5 ngày trước. Đang mởbug fixed Language Service
microsoft/vscode-cpptools#14868 · 2 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support for new "!" file exclusion syntaxCó thể đã có người làm @Colengms đã nhận 5 ngày trước. Đang mởbug Language Service
microsoft/vscode-cpptools#14867 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/vscode-cpptools
Issue tương tự
-
area:cli area:security bug priority:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
rtk-ai/rtk#5127 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
"code source" and "numerique.gouv" links: "new window" mention duplicated in the accessible nameĐang mởaccessibility
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
numerique-gouv/lasuite-landingpage#315 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs:triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
HyeokjaeChoi/vaultme#585 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement priority/P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
beettlle/pi-smart-router#200 ·