Eclipse CDT indexing not working to find declarations within the project

19,022

Ok, got it working. Actually whatever include paths I have included in Paths and Symbols are redundant and they make no difference as everything under Workspace/Project will be indexed.

The solution is very weird and it's related to scalability, which I came to know from this link. In Eclipse go to,

Window -> Preferences -> C/C++ -> Editor -> Scalability -> "Enable scalability mode when ..."

Set a huge number such as 500000 and press "OK". The problem was solved! For my case the actual set value was 5000 and the source file I was seeing was of 16k+ lines.

Share:
19,022
iammilind
Author by

iammilind

"Among programming languages, I am C++ ..." — BG 10.19...

Updated on June 27, 2022

Comments

  • iammilind
    iammilind almost 2 years

    I have installed Eclipse & CDT plugin on newly installed Ubuntu. The indexing is set to "Fast indexing" which is recommended ("Full Indexing" seems to have marginal difference).

    At so many places, if I press 'F3' ('show declaration') on any class name or include file name, the cursor remains stand still and it doesn't lead to the declaration. However, it works for standard files and symbols like, stdio.h, std::vector and so on.

    For example, I have 2 files,

    /home/myself/Workspace/Project/X/Y/include/file.h
    /home/myself/Workspace/Project/X/src/file.cpp
    

    I am not able to see any declaration of any class or variables displayed in file.cpp which are residing inside file.h. Even pressing 'F3' on #include"file.h", I am not able to go to file.h.

    Eclipse Workspace is created at Workspace folder the C++ project is created at Project folder. To store the include path, I have followed this procedure in Eclipse:

    Project -> Properties -> C/C++ General -> Paths and Symbols -> Library and Paths -> Add "/Project/X/Y/include/file.h" (used 'Workspace' and 'FileSystem' tabs both)

    But still no luck. I have done enough searching on internet and SO, but couldn't find anything useful. Note that, I am using eclipse only for code browsing and not for building the code as of now.

  • Captain Lepton
    Captain Lepton over 11 years
    It is a bad sign when you have a C++ file that big. Try refactoring a little just to help your sanity.
  • Admin
    Admin almost 9 years
    @Captain Lepton: or it's simply a sign you are using SWIG wrappers (or otherwise auto-generated code), or hardware device driver headers, or sqlite.h, or ... you get the point. It's not a bad sign per se.
  • Captain Lepton
    Captain Lepton almost 9 years
    I have worked with auto generated files including SWIG and various home grown systems for many years and wrote device drivers at my last job. None of these have to create monolithic files that cannot be factored out into more manageable logical units