5

I've been using VSCode for C language professionally almost everyday for +1 year. Right now, I hit with something that is really affecting my productivity.

When I open a big project, the features "Go to definition, Go to declaration, Peek..." etc don't work. I don't know how to describe how 'big' the project is. There are source files with +26k lines and it can take up to 45 min to compile. When I work with a more reasonably sized project, I have no issues, so until now I assumed this was a limitation of the program due to the size of my project and resigned myself. Now, I'm really bothered at this point and would like to find a solution.

What strikes me is that searching in the whole project (Ctrl + Shift + F) is blazing fast and works brilliantly, so VS seems to be capable of 'handling' this big project.

  • C/C++ extension from Microsoft last version v0.28.3
  • VSCode last version 1.46.1
  • Windows 10

Do you think there is a solution for this? Have you used VSCode with massive projects?

Edit: by 'don't work' I mean, it tries to perform the action but stays 'thinking' indefinitely.

user162889
  • 68
  • 1
  • 1
  • 5
  • Well, 26k lines is not "big". If you have 6 or 7 digit numbers of lines, I would call it "big", and beginning with 7 digits, "massive". It's not a pet project either, it's just small- to mid-sized. – the busybee Jul 03 '20 at 06:19

2 Answers2

5

Most propably it is not "Not working" but just "pretty slow". This is a known problem for C/C++ projects using the C/C++ extension for Visual studio code. The Indexer for intellisense needs some time (especially if you are not limiting it via limitSymbolsToIncludedHeaders or something like that). You could try reducing the amount of parsed files by using explizit browse paths in your c_cpp_properties.json like

"browse": {
  "path": [
    "/usr/include/",
    "/usr/local/include/",
    "${workspaceRoot}/../include",
    "${workspaceRoot}/dir1",
    "${workspaceRoot}/dir2",
    "${workspaceRoot}/dir3/src/c++",
    "${workspaceRoot}/dir5",
    "${workspaceRoot}/dir6/src",
    "${workspaceRoot}/dir7/src",
    "${workspaceRoot}/dir4"
],

and excluding for example IDE/SDK files where you do not need autocompletion/Go To Symbol/Go to definition.

For more explanation see: https://github.com/microsoft/vscode-cpptools/issues/1695

A.K.
  • 861
  • 6
  • 12
1

clangd plugin

For C I've had very good results with the clangd plugin: https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd which integrates clangd into vscode.

This plugin parses code using clang based on a compile_commads.json database which contains the exact compilation commands as produced by the build system, and as a result tends to produce the most accurate results possible.

I have covered it's setup in more detail at: VSCode "go to definition" not working

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985