4 ms·
I'd recommend using clangd together with the vscode-clangd extension instead of VSCode's "official" C/C++ extension. Properly set up with a compile_commands.jso
by tpush 7y ago
I'd recommend using clangd together with the vscode-clangd extension instead of VSCode's "official" C/C++ extension.
Properly set up with a compile_commands.json and its pretty much better than any C/C++ IDE I've ever used.
- frabert 7y agoccls works even better than clangd, in my experience.
- satysin 7y agoInteresting. I have used VSCode on Mac for C++ but it has been a royal pain in the ass recently with lldb-mi issues related to Catalina. If you don't mind sharing I am very interested in your setup.
- tpush 7y agoSure! I use CMake for all my projects, and passing "-D CMAKE_EXPORT_COMPILE_COMMANDS=ON" generates the compile_commands.json for clangd. I create a symlink to it in the main project folder so clangd can find it. Clangd embeds clang-format and clang-tidy, so given appropriate configuration files formatting in VSCode just works with no extra extensions but vscode-clangd. For debugging, I use CodeLLDB. Haven't had any problems with it so far, everything seems to work fine. Debug console works etc.
- pfranz 7y agoIn case you (or someone else reading this) didn't eventually find a workaround, here's how I was able to get lldb-mi to work in Catalina: https://github.com/microsoft/vscode-cpptools/issues/3829#issuecomment-578454043 https://github.com/microsoft/vscode-cpptools/issues/3829#iss... I also had the library issue mentioned here and copied the file the same way to fix that: https://github.com/microsoft/vscode-cpptools/issues/3829#issuecomment-599222739 https://github.com/microsoft/vscode-cpptools/issues/3829#iss...
- rvanlaar 7y agoCould you explain what is better? And how to properly set up compile_commands.json? It seems I struggled with getting `make` to work with VScode.
- zamalek 7y agoDebugging for one. You have to use a C++ debugger alongside Rust, and the lldb debugger is immensely superior (especially where structs are concerned in locals/watch). I strongly recommend you have a look at vcpkg for getting tooling such as make and gcc installed.
- chenzhekl 7y agoI would like to recommend the official C++ extension + CMake Tools. This combination provides great IDE-like experiences.
- zerr 7y agoIs it that hard for addons to implement proper settings GUI dialogs in vscode? Editing json files by hand is step backwards, especially when this comes from the company which also produces (real) Visual Studio.
- tpush 7y agoWhat settings are you referring to? VSCode's settings (both main and extensions) have a GUI view. The compile_commands.json is always generated and not meant to be edited at all.
- zerr 7y agoSettings of particular extensions, e.g. Golang's. When something is explained (e.g how to add build targets) it always goes to editing some json files.
- frosted-flakes 7y agoThe settings GUI in VS Code was only added in the past year or so. So it's likely that a lot of documentation hasn't been updated to mention this. Even so, I prefer editing the JSON files directly. I can easily see what's changed from the default, add comments, and make groups of settings.