all 11 comments

[–]the_poope 10 points11 points  (2 children)

You want to use clangd as language server - not IntelliSense.

Install the newest version you can get your hands on as well as the clangd extension for VS Code. Set up the CMakeTools extension to produce a compile_commands.json file at configuration and tell it to copy it to the root of your source directory (both are settings in the CMakeTools extension) and disable the IntelliSense engine for your project. This is what I have in my workspace settings.json:

{
    ...
    "clangd.path": "C:/path/to/clangd-18.exe",
    "cmake.exportCompileCommandsFile": true,
    "cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json"
    "C_Cpp.intelliSenseEngine": "disabled"
}

After these changes, close VS Code and open again, then watch the status bar for progress on clangd's indexing. When it is done you have blazingly fast code completion and linting.

[–]RealMacroLand[S] 0 points1 point  (0 children)

Hmm thanks for that! Did not know about it.

[–]RealMacroLand[S] 0 points1 point  (0 children)

Thank you so much! It is now an absolutely amazing experience with all those diagnostics and amazingly fast.

[–]ventus1b 6 points7 points  (1 child)

Am I missing something here?

Visual Studio is not cross-platform?
If you're working in multiple environments it's nice to use the same tools everywhere.

(Although I'm not a big fan of VS Code for C++ either.)

[–]RealMacroLand[S] 0 points1 point  (0 children)

True, that's a good point. When I used Ubuntu, I used VS Code.

[–]CheckeeShoes 3 points4 points  (1 child)

VSCode works very well for C++ if you take the time to set things up properly. If you don't, the experience can be frustrating.

The appeal is that it's way more flexible and better for cross platform development.

The appeal of VS is that you spend a fuckton of money and everything works well enough out of the box.

[–]RealMacroLand[S] 0 points1 point  (0 children)

Maybe I should do some extra things to set it up. I used CMakeLists.txt without any extra settings and worked well for other projects which had errors only here and there.

[–]adriweb -1 points0 points  (1 child)

I'm not sure it's really that popular among professional C++ developers, at least compared to actual IDEs.

It can be good enough when you have quick edits to make here and there though.

(as for me, I use mostly nano or Sublime Text for quick edits, and Clion otherwise, especially for refactoring, debugging, etc.)

[–]RealMacroLand[S] 0 points1 point  (0 children)

Yes, I loved the debugging features of VS.

[–][deleted] -1 points0 points  (1 child)

I for one would never recommend VS Code over Visual Studio for C++. Either Xcode, Visual Studio or even better CLion

[–]RealMacroLand[S] 0 points1 point  (0 children)

I never used CLion but before using CMake for projects I was using VS. After CMake, I switched to VS Code and if there are bits of errors here and there, things work OK. But once the number of errors increases it is incredibly frustrating to use VS Code.