7

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.

iammilind
  • 68,093
  • 33
  • 169
  • 336

1 Answers1

15

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.

iammilind
  • 68,093
  • 33
  • 169
  • 336
  • 1
    It is a bad sign when you have a C++ file that big. Try refactoring a little just to help your sanity. – Captain Lepton Oct 16 '12 at 17:10
  • 3
    @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_. –  May 04 '15 at 10:22
  • 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 – Captain Lepton May 18 '15 at 15:59