(Note: this OP is a properly split part of this question, after this correct comment. The original question was suitably adapted. All this improves SO.)
I am slowly migrating from Eclipse CDT to VSCode with C/C++ Extension Pack. I am working under Ubuntu 22, with g++.
I have a large C++ package, with its own CMake files.
Note that, when working at the command prompt, I use CMake to generate makefile
s, and then compiling/linking with make <flags> <target>
.
I don't use cmake --build
, e.g. (This is simply an "inherited" procedure in a large project, and I never bothered changing that. If I were to start from scratch I would probably do so, and I might in the future).
So the fact that I generate my makefile
s with CMake is likely anecdotic.
When working in Eclipse, I am used to quick-navigating compilation errors. I.e., whenever a compilation error shows up, I can double click on an item in the list of errors to go straight to the line producing it.
Can I perform this with VSCode?
Note that I don't even know how to configure VSCode to produce the intended list of compilation errors, via a suitably configured make
build task (my current way to build).
See Setup make build tasks with externally created makefiles in Visual Studio Code with C++
Whether you use a build task, or the
ms-vscode.makefile-tools
extension, or the CMake Tools extension, if you get compiler diagnostics in the integrated terminal from running a build, VS Code's supports several common file+line patterns and will make those patterns into links that you can click into when holding down your link modifier (typically ctrl/cmd or alt/opt).If you use a build task, you can select a problem matcher from those contributed by the C/C++ extension such as
$gcc
or$msvc
so that diagnostics matched from the output of the build task will be used as VS Code Problems (error squiggly underlines and listed in the Problems Panel, where you should be able to click them to jump to them in the editor area of the workbench).And then there's the fact that as long as you've configured the C/C++ configuration provider appropriately (Ex.
"C_Cpp.default.configurationProvider": "ms-vscode.makefile-tools",
in settings.json), then the C/C++ extension will perform analysis and also contribute Problems (squiggles and items in the Problems Panel, which you can also click to navigate to the source code in the editor area). If you want to disable this and just rely on a build task's problem matcher, then put"C_Cpp.intelliSenseEngine": "disabled",
in your settings.json.