这篇博客已经写的很好了,就不再叙述。这里说明几个要点:

  1. 确保compile_commands.json文件的路径正确:在VSCode中,打开命令面板(Ctrl+Shift+P),输入"C/C++: Edit Configurations (JSON)"并选择该选项。确保compile_commands.json的路径与实际位置匹配。如果文件在项目根目录下,可以使用相对路径或绝对路径。

  2. 安装并启用"C/C++"插件:确保你已经安装了VSCode的"C/C++"插件。在扩展选项卡中搜索"C/C++"并安装插件。然后重新启动VSCode。

  3. 更新或重新生成compile_commands.json文件:如果你的项目配置发生了更改,例如添加或删除了文件,可能需要更新或重新生成compile_commands.json文件。根据你的项目构建系统,可以使用不同的工具来生成compile_commands.json文件,例如CMake或Bear。确保重新生成并替换了旧的compile_commands.json文件。

  4. 检查项目配置:确保compile_commands.json文件中包含了正确的编译选项和文件路径。你可以手动打开compile_commands.json文件,检查其中的内容是否正确。确保文件路径和编译选项与你的项目设置一致。

  5. 检查VSCode的用户设置:在VSCode中,打开用户设置(File -> Preferences -> Settings)并搜索"C/C++“。检查与C/C++相关的设置是否正确配置。特别注意"C_Cpp.default.compileCommands"选项是否设置为"compile_commands.json”。

  6. 检查C/C++扩展的输出:在VSCode底部的状态栏中,点击C/C++的图标,可以查看C/C++扩展的输出。检查是否有任何与compile_commands.json相关的错误或警告消息。

GitHub 加速计划 / js / json
19
5
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:4 个月前 )
f06604fc * :page_facing_up: bump the copyright years Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :page_facing_up: bump the copyright years Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :page_facing_up: bump the copyright years Signed-off-by: Niels Lohmann <niels.lohmann@gmail.com> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me> Signed-off-by: Niels Lohmann <niels.lohmann@gmail.com> 1 个月前
d23291ba * add a ci step for Json_Diagnostic_Positions Signed-off-by: Harinath Nampally <harinath922@gmail.com> * Update ci.cmake to address review comments Signed-off-by: Harinath Nampally <harinath922@gmail.com> * address review comment Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix typo in the comment Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix typos in ci.cmake Signed-off-by: Harinath Nampally <harinath922@gmail.com> * invoke the new ci step from ubuntu.yml Signed-off-by: Harinath Nampally <harinath922@gmail.com> * issue4561 - use diagnostic positions for exceptions Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix ci_test_documentation check Signed-off-by: Harinath Nampally <harinath922@gmail.com> * address review comments Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix ci check failures for unit-diagnostic-postions.cpp Signed-off-by: Harinath Nampally <harinath922@gmail.com> * improvements based on review comments Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix const correctness string Signed-off-by: Harinath Nampally <harinath922@gmail.com> * further refinements based on reviews Signed-off-by: Harinath Nampally <harinath922@gmail.com> * add one more test case for full coverage Signed-off-by: Harinath Nampally <harinath922@gmail.com> * ci check fix - add const Signed-off-by: Harinath Nampally <harinath922@gmail.com> * add unit tests for json_diagnostic_postions only Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix ci_test_diagnostics Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix ci_test_build_documentation check Signed-off-by: Harinath Nampally <harinath922@gmail.com> --------- Signed-off-by: Harinath Nampally <harinath922@gmail.com> 1 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐