Remix.run Logo
rs186 2 months ago

The intellisense from clangd is much better and faster than the Microsoft C++ extension, if you can set up a compile_commands.json. Although debugging still relies on the Microsoft extension. Although I don't think it's going to be hard to create an extension just for debugging (if it does not already exist?)

geertj 2 months ago | parent | next [-]

Yes, even on medium sized code bases (few 100K lines), the Microsoft C++ extension gets extremely slow. Clangd is a much better option.

senderista 2 months ago | parent | prev | next [-]

Not just faster, I have never been able to get jump to declaration/definition/references to work reliably without clangd.

starkrights 2 months ago | parent | prev | next [-]

Is there a ‘right’ (or simple/direct) way to generate this using various buildchains? I remember setting this up so I could use Sublime with intellisense a while ago, and finding that I could only get it to generate with a specific compiler chain on windows (ninja I think?)

Minor annoyance to have to make my c make project generate buildchain files for a compiler I’m not using & copy that file into my project root to commit it- unrelated to the original question, but also annoying that I have to manually generate it every time I make significant codebase changes.

TuxSH 2 months ago | parent [-]

> and finding that I could only get it to generate with a specific compiler chain on windows (ninja I think?)

Yes, you're right about that.

Basically, it boils down to "use CMake with Ninja/Makefile" (even if you don't strictly have to, you could write a script that creates the json yourself, for example). When cross-compiling, you may also have to whitelist compiler paths.

Add -DCMAKE_EXPORT_COMPILE_COMMANDS=ON as command-line arg during the config step, or add the equivalent "set" call to your CMakeLists.txt, restart clangd (ctrl+p, restart clangd), and you're good to go.

There are minor annoyances when cross-compiling (it using clang -- some compile options are incompatible and need to be removed in global user config, and it not extracting default compiler defines from compilers) but they are very easily worked around

I more or less use this as config: https://gist.github.com/TuxSH/0220d1235dace77f82738c96718011...

nomad41 2 months ago | parent | prev | next [-]

I've had the opposite experience with weird C++ projects from some customers that use external toolchains. For some reason even creating the compile_commands.json file with Bear doesn't work, while the proprietary Intellisense extension works out of the box without any configuration.

Rucadi 2 months ago | parent | prev | next [-]

Lldb and rr (midas) have vscode extensions

IshKebab 2 months ago | parent | prev | next [-]

I agree. It's way better. You can use the CodeLLDB extension for debugging.

https://github.com/vadimcn/codelldb

Melonai 2 months ago | parent | prev [-]

There are other third-party extensions which rely on the Microsoft C++ one. I have recently ran into this problem with my VSCodium setup.