Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » CDT Indexer is refusing to Index some files(CDT Indexer is refusing to Index some files)
CDT Indexer is refusing to Index some files [message #1748576] Thu, 24 November 2016 16:24 Go to next message
Eclipse UserFriend

I have been using Eclipse CDT for some years and there's always been an issue or two which were always a pain in the butt, but the problems that CDT Indexer has gave me in the pass, were without doubt the worse.

Now I have a new issue. It seems that Eclipse CDT is refusing to index some files in my tree and I don't know why. The indexer simply refuses to index them and doesn't tell me why. Because of that, defined classes and namespaces aren't seen in other source files.

i'm using Eclipse Neon.1 (4.6.1) Build ID M20160907-1200
and CDT is 9.1.0.201609121658

Has anyone had a similar issue in the past?
Force an full index refresh inside the project does not help. I'm also unable to replicate the issue in a simple example.
Re: CDT Indexer is refusing to Index some files [message #1748704 is a reply to message #1748576] Sun, 27 November 2016 11:42 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
It does that at times usually for library headers.
If it's your own directory, check that the directory is in the Indexer includes
You can check this by expanding Includes under the project in Project View.
If it's not there, then you will have to add it using Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc.
http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_prop_general_sd_entries.htm

Other than that, you haven't supplied enough information.
For instance., does it compile?
What are your specific indications it isn't indexing (at least one example)

Re: CDT Indexer is refusing to Index some files [message #1749460 is a reply to message #1748704] Wed, 07 December 2016 02:06 Go to previous messageGo to next message
Eclipse UserFriend
I'm sorry for the slow answer. I didn't noticed that there was a response to the post.

You asked if the code compiles. Yes it does. GCC does not complain and correctly compiles the code.

Yes, the header directory is in the Indexer includes, as it has always been.

Regarding the specific indications, I created a parser log file for the specific library header.
The log file provided an indication that one of the Included headers was not being indexed. The header file location was provided after the "Unresolved includes (from headers in index):" notation.

These false-negatives are quite problematic because they sometimes induce me in error. They make me look for errors that do not exist and slowdown my speed of development.

BTW, I have updated Eclipse to Neon.2 and CDT to 9.2RC4
The issue still prevails.

[Updated on: Wed, 07 December 2016 02:08] by Moderator

Report message to a moderator

Re: CDT Indexer is refusing to Index some files [message #1749461 is a reply to message #1749460] Wed, 07 December 2016 02:42 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Don't know what to say. You haven't provided much more information than the original post. Telling us you have an indication but not providing specifics won't get you too far. Not that doing so will guarantee a resolution. It could be a bug.

I haven't had any problems with the Indexer except in specific instances with C+11 std library headers. I suspect it's something in your code that's the trigger.

It's possible to add code that only the Indexer can see which may help.
Surround the code with #ifdef __CDT_PARSER__ ...#endif
https://www.eclipse.org/forums/index.php/t/1068546/
What that code may be depends on the rest of the code. It could be something as simple as defining a macro or a minimal class definition.

If you want, you can file a bug : https://bugs.eclipse.org/bugs/
However, unless there is something you can fix yourself, you won't get much satisfaction.

You will need a small, reproducible example that exhibits the problem. Who knows? In trying to make one you may discover what it is you need to do.

[Updated on: Wed, 07 December 2016 02:47]

Report message to a moderator

Re: CDT Indexer is refusing to Index some files [message #1749464 is a reply to message #1749461] Wed, 07 December 2016 03:45 Go to previous messageGo to next message
Eclipse UserFriend
Hmm :/
The only way of providing any info, would be to provide the entire project... :/
I will try to isolate and replicate the issue with a smaller example.

Thank you for the support and help.
Re: CDT Indexer is refusing to Index some files [message #1749549 is a reply to message #1749464] Thu, 08 December 2016 02:51 Go to previous messageGo to next message
Eclipse UserFriend
OK, this is getting weirder...
I have inspected my code and I was able to remove all of the false error markings.
It seems there was a problem in another header file, along the inclusion tree, which was causing the issue. The thing is, I'm unable to reproduce it in a smaller confined setup :/
For what I can understand, there must be some issues with the indexer when resolving very deep namespaces (ex: A::B::C::D::E::F) and unnamed namespaces. I have some of these in my project.
Because of those false warnings, the indexer was having a weird behaviour, not being able to correctly pin-point the location of declared types.

I will try to continue to see if I'm capable of creating an example. I will then post it here.

Re: CDT Indexer is refusing to Index some files [message #1749582 is a reply to message #1749549] Thu, 08 December 2016 10:40 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
I am glad you have made some progress with this, including some basic information.

Quote:
I will try to continue to see if I'm capable of creating an example. I will then post it here.


What would be useful is filing a bug https://bugs.eclipse.org/bugs/enter_bug.cgi?product=CDT so that it can be fixed. The indexer has been under pretty active improvements recently and all that it needs is some test cases. Even if you submit the bug with what you have determined so far it may be enough for the active maintainers in that area of the code to understand what is going on. Obviously an MCVE helps a lot too and increases the chances that anything gets done.
Re: CDT Indexer is refusing to Index some files [message #1750580 is a reply to message #1749582] Fri, 23 December 2016 02:00 Go to previous messageGo to next message
Eclipse UserFriend
OK, I have some news.

On my chase to try to have an example, I was not completely successfully, but I have found a way to replicate a behaviour which goes on the same line of what I have described previously.
I am able to replicate this weird behaviour.
This issue appears for CDT 9.2 in Eclipse Oxygen.

So, in this case, it seems that the CDT indexer gets confuse when two classes with the same name, are implemented in two different files wherever if they are modules or headers.

How Replicating the bug:

Three files side-by-side in the project root.

mod1.cpp contains:
class Blah{
    int x {0};

  public:
    Blah() = default;
    int get(){ return this->x; }
};

int main(){
  Blah a;
  a.get();
  return 0;
}


mod2.cpp contains:
#include "test.hpp"

int main(){
  Blah a;
  a.get();
  a.getVal();
  return 0;
}



test.hpp contains:
#ifndef TEST_HPP_
#define TEST_HPP_

class Blah{
    int x {0};

  public:
    Blah() = default;
    int getVal(){ return this->x;}
};

#endif /* TEST_HPP_ */


Now, if I add those files to a basic C++ project and Force a rebuild of the project, the indexer will show an error in the source "mod2.cpp" saying that a.get() cannot be resolved.
But then, I modified the test.hpp header, but just adding a single space and saving the file. After saving the file, the indexer will no longer show the error and will indicate that both "getVal()" and "get()" methods are valid for class "Blah"
The following image can provide a visual info of what is going on.
https://www.dropbox.com/s/yhwd8yh9nqv233m/IndexerIssue.png?dl=1

If I force the indexer to rebuild again, the indexer error will show once again. If I again, modify the test.hpp header by adding or removing a single space and then save the file, the issue will again appear.
Re: CDT Indexer is refusing to Index some files [message #1750646 is a reply to message #1750580] Fri, 23 December 2016 19:08 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
So what you are saying is that the Indexer doesn't handle conflicting definitions well.
What you are doing is legal but strange.
The obvious workaround is don't do it.

The indexer tries to cache what it has found.
In your case, caching doesn't work because the definition of "Blah" changes between modules.

The only way to fix this is to have different indices for each module or a complete lack of caching. Perhaps a cache size of zero would cause the Indexer to build after every save. Currently though, this isn't possible.

What's happening doesn't seem like a bug to me. More of a side-effect. Perhaps you should submit an enhancement request to allow disabling caching but the disabling may affect other things adversely.





Re: CDT Indexer is refusing to Index some files [message #1750647 is a reply to message #1750646] Fri, 23 December 2016 19:19 Go to previous messageGo to next message
Eclipse UserFriend
Why would it be strange? This is just a simple example.
There is no problem in having two modules that generate two different executables for say, two different targets in a makefile.
Anyway, the indexer should handle this without problem. Not handling it means there is no isolation between the parsed information for each module.
Re: CDT Indexer is refusing to Index some files [message #1750652 is a reply to message #1750647] Fri, 23 December 2016 20:46 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
What's strange is having two different class definitions with the same name within the same project. The class Blah in mod1.cpp is NOT the same as the definition used in mod2.cpp. From a maintenance and documentation viewpoint this is a potential nightmare. The normal approach when two definitions are the same but for X, Y and Z is to extend the lesser by inheritance using it as a base class and providing X,Y and Z in the extended class. Spending a lot of effort to fix what appears to be a problem only exhibited by this example is not a worthwhile endeavor when it's so easily circumvented.

One of the problems with trying to please everybody is that, no matter what, someone will still come along and demand that their way be accommodated too -- even if they are a minority of one.

Quote:
Not handling it means there is no isolation between the parsed information for each module.

Which would defeat caching or would mean having individual caches based on module.

Quote:
There is no problem in having two modules that generate two different executables for say, two different targets in a makefile.

Correct, there isn't. I do it all the time but I wouldn't want two different classes sharing the same name.

Sounds like what you want are two or more projects. If only to separate out the similar but different definitions.


Re: CDT Indexer is refusing to Index some files [message #1750655 is a reply to message #1750652] Fri, 23 December 2016 21:54 Go to previous messageGo to next message
Eclipse UserFriend
I understand your point of view and I'm not saying that you are not right. You are.
What I am trying to say is, if the indexer is not isolating each module, then it means it can leak information (maybe also namespace information) from one module to another under weird circumstances.
The issue that I explained previously, may or may not be a consequence of such leakage.

I attempted to fill a bug report but it seems the issue tracker does not allow me to fill bug reports without administration approval.
I do not know if this issue is valid or important enough to even contact an admin to get such permissions...

[Updated on: Fri, 23 December 2016 21:55] by Moderator

Report message to a moderator

Re: CDT Indexer is refusing to Index some files [message #1750722 is a reply to message #1750655] Tue, 27 December 2016 12:04 Go to previous messageGo to next message
Eclipse UserFriend
Hello again!

I believe I have isolated the bug that is causing me problems. It has to do with a mix of using a shared_ptr as an object attribute and using friendship declarations.
The code that I used, follows.

For the object.hpp
#ifndef OBJECT_HPP_
#define OBJECT_HPP_

namespace stuff {
  class Object{
    friend class Builder; // Only connector can instantiate a Builder object.

    explicit
    Object()
    {};

    public:
      virtual
      ~Object() = default;
  };
}

#endif /* OBJECT_HPP_ */



For the builder.hpp
#ifndef CONNECTOR_HPP_
#define CONNECTOR_HPP_

#include <memory>
#include "object.hpp"

namespace stuff {
  class Builder{
    public:
      enum class OPTIONS : uint32_t{
        OPTION_1 = 1,
      };

    private:
      std::shared_ptr<OPTIONS> opts {nullptr};

    public:
      Builder() = default;

      virtual
      ~Builder() = default;

      explicit
      Builder(const Builder::OPTIONS& ops)
      : opts {std::make_shared<OPTIONS>(ops)}
      {}
  };
}

#endif /* CONNECTOR_HPP_ */



For the main.hpp
#include <iostream>
#include "builder.hpp"
#include "object.hpp"

using namespace std;
using namespace stuff;

int main() {
  Builder c(Builder::OPTIONS::OPTION_1);

  return 0;
}



For some reason unknown to me, the indexer fails to index properly the builder.hpp header.
If I force an indexer rebuild, this region of the code
Builder c(Builder::OPTIONS::OPTION_1);
will be marked as an error, because the indexer is unable to find the symbol OPTION_1
I tracked this issue to the 'shared_ptr' in 'builder.hpp'. It seems that the reason for this behaviour, is in the 'shared_ptr' initialisation. If I remove the 'nullptr' and just let the 'shared_ptr' initialise by itself, this issue will not happen.
I also found out that, if I force an error to occur, for example, by adding 'std::' behind 'nullptr', saving the file, let the indexer point out the error, removing that same 'std::', saving again and letting the indexer work once again, the behaviour will not repeat itself.

The following printscreen may help to see the issue.
https://www.dropbox.com/s/h53fwwimuc8fayg/shared_ptr.png?dl=1

[Updated on: Tue, 27 December 2016 19:41] by Moderator

Report message to a moderator

Re: CDT Indexer is refusing to Index some files [message #1750953 is a reply to message #1750722] Mon, 02 January 2017 17:28 Go to previous messageGo to next message
Jonas Lindgren is currently offline Jonas LindgrenFriend
Messages: 2
Registered: January 2017
Junior Member
Carlos Ferreira wrote on Tue, 27 December 2016 12:04

I tracked this issue to the 'shared_ptr' in 'builder.hpp'. It seems that the reason for this behaviour, is in the 'shared_ptr' initialisation. If I remove the 'nullptr' and just let the 'shared_ptr' initialise by itself, this issue will not happen.


This exact bug appeared in my project as well. One class just wouldn't index and I tried everything I could think of. Turns out the class was initializing a std::shared_ptr to null, which caused the error. No indication anywhere in Eclipse what was going on, the indexer just silently failed.

Thanks for this thread. I have already spent days trying to resolve this issue, an issue that came back on and off over a period of several years for every version of Eclipse I have tried. Without this thread I would probably have gone on for quite a while yet.

Has this bug-report been filed? It definitely needs to be, IMO.
Re: CDT Indexer is refusing to Index some files [message #1750954 is a reply to message #1750722] Mon, 02 January 2017 18:02 Go to previous messageGo to next message
Jonas Lindgren is currently offline Jonas LindgrenFriend
Messages: 2
Registered: January 2017
Junior Member
For fun I created a small test-case showcasing the bug I'm experiencing:

foo.h
#ifndef FOO_H_
#define FOO_H_

#include <memory>

class Foo {
public:
	std::shared_ptr<int> m_variable = nullptr;
};

#endif /* FOO_H_ */


main.cpp
#include <memory>
#include "foo.h"

int main() {
	Foo a;

	std::exit(0);
}


The entire thing compiles just fine using g++ (GCC) 6.2.1 20160830, but Eclipse Neon.2 Release (4.6.2) Build id: 20161208-0600 shows an error in main.cpp around Foo, unable to resolve the class, since it hasn't been indexed. Removing the " = nullptr" from foo.h solves the problem once the index has been rebuilt.

indexer-log from main.cpp:
Project:               eclipse_error
File:                  file:/home/jonas/eclipse_workspaces/c++/eclipse_error/main.cpp
Language:              GNU C++
Index Version:         206.0
Build Configuration:   Debug
Context:               file:/home/jonas/eclipse_workspaces/c++/eclipse_error/main.cpp
   C++, {}
Versions in Index:     1
   C++: {}; 0 macros, 2 includes, 5 names;

Include Search Path (option -I):
   /home/jonas/eclipse_workspaces/c++/eclipse_error
   /usr/include/c++/6.2.1
   /usr/include/c++/6.2.1/x86_64-pc-linux-gnu
   /usr/include/c++/6.2.1/backward
   /usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1/include
   /usr/local/include
   /usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1/include-fixed
   /usr/include

...

Unresolved includes (from headers in index):
   file:/home/jonas/eclipse_workspaces/c++/eclipse_error/foo.h is not indexed

Unresolved names:
   Attempt to use symbol failed: Foo in file /home/jonas/eclipse_workspaces/c++/eclipse_error/main.cpp:5

Written on Mon Jan 02 18:49:46 CET 2017
Re: CDT Indexer is refusing to Index some files [message #1750987 is a reply to message #1750953] Tue, 03 January 2017 13:55 Go to previous messageGo to next message
Eclipse UserFriend
Hei Jonas! I was starting to think that I was the only one being affected by these weird bugs.

I have requested authorisation from the Eclipse Webmaster, to write bug reports.
Once I get it, I will fill one and link it here.
Re: CDT Indexer is refusing to Index some files [message #1750999 is a reply to message #1750987] Tue, 03 January 2017 15:12 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
Hi Carlos and Jonas,

Thank you for taking the time to submit a bug report on this issue. You have already done the biggest part of the problem which is creating a reproducible test case.

Thanks!
Jonah
Re: CDT Indexer is refusing to Index some files [message #1751023 is a reply to message #1750999] Tue, 03 January 2017 17:23 Go to previous messageGo to next message
Eclipse UserFriend
I have filled a bug request. It can be found here.
Re: CDT Indexer is refusing to Index some files [message #1809386 is a reply to message #1751023] Mon, 15 July 2019 10:17 Go to previous messageGo to next message
Pedro Becerra is currently offline Pedro BecerraFriend
Messages: 4
Registered: July 2019
Junior Member
Hi all.
I have simillar problem.
Indexer does not index some files and I cannot find out why.
I attached three indexer log files to let you see the unindexed files in case som one could help.
CCoreis the first one. It includes CGrfics wich includes CSprite.
The project is so much bigger but I hope that with only these files some one could help.
Thakns.
Re: CDT Indexer is refusing to Index some files [message #1809492 is a reply to message #1809386] Tue, 16 July 2019 21:03 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
You have missing includes from dir libxml

If it is in your project , is it on any of the include paths
used by the indexexr?

You may need to add a User Entry thathat provides a path to libxml

This could be causing the indexer to give up.
Fix it and see.

[Updated on: Tue, 16 July 2019 21:05]

Report message to a moderator

Re: CDT Indexer is refusing to Index some files [message #1809521 is a reply to message #1809492] Wed, 17 July 2019 09:30 Go to previous messageGo to next message
Pedro Becerra is currently offline Pedro BecerraFriend
Messages: 4
Registered: July 2019
Junior Member
Thaks a lot for your response.
I've added the include as you suggested me but every thing is the same.
I atached a new log to let you see that libxml is included, and "usr/include/c++/9.1.0/" is also included but indexer does not index "usr/include/c++/9.1.0/list"
I've also the option -std=c++0x
And i've shorted the workspace name.

[Updated on: Wed, 17 July 2019 09:37]

Report message to a moderator

Re: CDT Indexer is refusing to Index some files [message #1809533 is a reply to message #1809521] Wed, 17 July 2019 15:02 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Is /usr/include/c++/9.1.0/list a file?
It looks like a drectory name.
Most includes have an ext.
Is it for std::list?

Plus there is a discrepancy between what you use as path
and what the indexer reports.

You are saying usr/... And the indexer says /usr/....
There is a difference.

If it really is a file,
try opening it in an editor window and then index it.

The only other suggestion I have is to try to simplify the code
to isolate the problem

[Updated on: Wed, 17 July 2019 21:18]

Report message to a moderator

Re: CDT Indexer is refusing to Index some files [message #1809674 is a reply to message #1809533] Fri, 19 July 2019 17:28 Go to previous message
Pedro Becerra is currently offline Pedro BecerraFriend
Messages: 4
Registered: July 2019
Junior Member
Thanks again for responding.
If you have a look at file I uploaded you could see the path is /usr/...
I just untyped the '/' on my comment :(
And yes, /usr/include/c++/9.1.0/list is a file. I don't know why it's fashionable to write includes without .h or .hpp but there are alot (iostream, cfloat, cinttypes...). I don't like it but is not my decissión. Sure there is a reason.
I could see that the eclipse indexer doesn't like forward declarations nor namespaces. I'm removing all of them I can, but there are a lot of files that are not indexed yet. The #include "bla.h" is not marked as error, but whe I write:
class blo:public bla {...};
indexer marks symbol bla could not be resolved. And is well declared in bla.h . And c++ compiles it with out errors.
I've attached an screen shot of the file that is miss indexed to let you see strange coloring. I'ts funny to see a single word in two colors. (It's just a couriosity)
Have a nice weekend.



  • Attachment: Captura.PNG
    (Size: 92.63KB, Downloaded 211 times)
Previous Topic:How do I avoid references to absolute paths in the generated makefile? (for linked source files)
Next Topic:Arduino Due Native USB Port
Goto Forum:
  


Current Time: Tue Apr 23 16:42:02 GMT 2024

Powered by FUDForum. Page generated in 0.05893 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top