Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Indexer detects wrong include file of two possibilities
Indexer detects wrong include file of two possibilities [message #989026] Tue, 04 December 2012 10:54 Go to next message
Dirk Wibben is currently offline Dirk WibbenFriend
Messages: 50
Registered: February 2010
Member
Hello.

I'm using Eclipse Juno with CDT 8.1 on Windows.

I'm developing software mainly for a Target microcontroller. But I have the possibility to generate code for a Simulation of the code on a PC.

To separate between 'Target' and 'Simulation' I use two different Output directories:
'Target' = 'bin'
'Simulation' = 'sim'.

Underneath those directories there is a similar tree with a header file of the same name but different content ('Target' or 'Simulation'):

<Project dir>
- bin
-- include
--- generated
---- autoconf.h
:
:
-sim
-- include
--- generated
---- autoconf.h
:

Somewhere in my code there is

#include <generated/autoconf.h>

And here is my problem:

When I 'follow' this include (F3 or Strg-Click), I ALWAYS get the 'autoconf.h' from sim. And therefore the Eclipse Indexer is highlighting for 'sim' and not for 'bin' as I request.

I have already inserted in
<Project Properties> | C/C++ General | Paths and Symbols | Includes | GNU C
the entry

<Project path>/bin/include


What do I have to do to create a Configuration, in which the upper 'F3' brings me to the include of the bin folder???

TIA
Dirk


Best regards
Dirk
Re: Indexer detects wrong include file of two possibilities [message #989075 is a reply to message #989026] Tue, 04 December 2012 14:33 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
You should create two build configurations
http://help.eclipse.org/juno/topic/org.eclipse.cdt.doc.user/reference/cdt_u_prop_manage_dialog.htm?cp=11_4_7_0_2_0

Then in Project Properties set the source location for every build config
http://help.eclipse.org/juno/topic/org.eclipse.cdt.doc.user/reference/cdt_u_prop_general_pns_src.htm?cp=11_4_7_0_4_5_4

In C/C++ Project Properties, C/C++ Indexer
http://help.eclipse.org/juno/topic/org.eclipse.cdt.doc.user/reference/cdt_u_prop_general_idx.htm?cp=11_4_7_0_4_3

you can select which build configuration the indexer will use.


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Indexer detects wrong include file of two possibilities [message #989082 is a reply to message #989075] Tue, 04 December 2012 15:01 Go to previous messageGo to next message
Dirk Wibben is currently offline Dirk WibbenFriend
Messages: 50
Registered: February 2010
Member
Axel Mueller wrote on Tue, 04 December 2012 15:33
You should create two build configurations
http://help.eclipse.org/juno/topic/org.eclipse.cdt.doc.user/reference/cdt_u_prop_manage_dialog.htm?cp=11_4_7_0_2_0


Yes . . . I understand that.

Axel Mueller wrote on Tue, 04 December 2012 15:33
Then in Project Properties set the source location for every build config
http://help.eclipse.org/juno/topic/org.eclipse.cdt.doc.user/reference/cdt_u_prop_general_pns_src.htm?cp=11_4_7_0_4_5_4


This I don't understand.

Here is my project structure (also as attachment):

index.php/fa/12593/0/

'bin' and 'sim' are in the SAME project parallel by the source folders.
The 'Source Location' for BOTH build configs would therefore be 'GV642_Premium_Bosch' !?!?

Axel Mueller wrote on Tue, 04 December 2012 15:33
In C/C++ Project Properties, C/C++ Indexer
http://help.eclipse.org/juno/topic/org.eclipse.cdt.doc.user/reference/cdt_u_prop_general_idx.htm?cp=11_4_7_0_4_3

you can select which build configuration the indexer will use.


If the second point above is clear, then I fully understand the last point.


THX for the help.

Regards
Dirk


Best regards
Dirk
Re: Indexer detects wrong include file of two possibilities [message #989416 is a reply to message #989082] Thu, 06 December 2012 07:26 Go to previous messageGo to next message
Dirk Wibben is currently offline Dirk WibbenFriend
Messages: 50
Registered: February 2010
Member
Sorry . . . but *BUMP*.

At least I would like to know, how/why the Indexer prefers the 'sim' directory over the 'bin' directory?
And how can I change/revert that 'attitude'?

THX in advance.


Best regards
Dirk
Re: Indexer detects wrong include file of two possibilities [message #989507 is a reply to message #989082] Thu, 06 December 2012 14:36 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
You can define exclude filters for the source location.
e.g.
Config1
source location GV642_Premium_Bosch
exclude bin

Config2
source location GV642_Premium_Bosch
exclude sim

see
http://help.eclipse.org/juno/topic/org.eclipse.cdt.doc.user/reference/cdt_u_prop_general_pns_src.htm?cp=11_4_7_0_4_5_4


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Indexer detects wrong include file of two possibilities [message #989654 is a reply to message #989507] Fri, 07 December 2012 08:17 Go to previous messageGo to next message
Dirk Wibben is currently offline Dirk WibbenFriend
Messages: 50
Registered: February 2010
Member
Hello Axel,

first THX for the reply.

I'm sorry, but that didn't work either.
I have excluded 'sim' in 'Source location' and did a 'Rebuild Index'.
Then I have navigated again and I ended again falsely in 'sim'.
This screenshot is the situation directly after the last 'F3':

index.php/fa/12630/0/

Even as 'autoconf.h' is (obviously) excluded, it is highlighted and opened in an editor. Confused

And here are the 'Indexer' settings in the PROJECT:

index.php/fa/12631/0/

Is there the possibility of a bug in CDT?

My only way to get it working properly is to RENAME the 'sim' folder and 'Rebuild Index'.


Best regards
Dirk
Re: Indexer detects wrong include file of two possibilities [message #989687 is a reply to message #989654] Fri, 07 December 2012 10:19 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Did you add sim folder in Project Properties->General->Paths and Symbols->Includes?

Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Indexer detects wrong include file of two possibilities [message #989932 is a reply to message #989687] Mon, 10 December 2012 07:07 Go to previous messageGo to next message
Dirk Wibben is currently offline Dirk WibbenFriend
Messages: 50
Registered: February 2010
Member
Nope.

On the opposite I've even added 'bin' and 'bin\generated' as Includes with no success.


Best regards
Dirk
Re: Indexer detects wrong include file of two possibilities [message #1796994 is a reply to message #989932] Tue, 23 October 2018 16:17 Go to previous messageGo to next message
Dave Hitchman is currently offline Dave HitchmanFriend
Messages: 9
Registered: August 2018
Junior Member
What does it take to get eclipse to index correctly? It doesnt appear able to actually go and look in the right file
header1.h
struct fred{
int a
}fred_t;

header2.h
struct fred{
int b
};

file.c
fred _t*ptr

goes to header2 EVEN THOUGH HEADER2 is NOT EVER INCLUDED IN THE PROJECT but just happens to be in the same tree!
Re: Indexer detects wrong include file of two possibilities [message #1797024 is a reply to message #1796994] Wed, 24 October 2018 08:57 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
I tried this with a sample HelloWorld project.
Not sure what you were trying to do
but header1.h is declaring a variable named fred_t as struct fred .
It should have a typedef.

In any case, using Photon (4.8.0) and CDT (9.5.2.2018071141),
I get the proper file from an F3
although I get a syntax error without the typedef.

When I hover over fred_t in main.c I get the proper definition.

You don't say which Eclipse and CDT you are using.

I don't think there is any way to stop the Indexer from scanning files in a directory unless the directory is marked as
Excluded (RC dir in Project View --> Resource Configurations --> Exclude from Build ...)
and the Index Source files not included in the build is deselected.
(Project --> Properties --> C/C++ General --> Indexer)

The Indexer doesn't handle multiple definitions nicely though.
This is particularly true of macros.
The test I ran is rather simple.
Perhaps a more complicated one would confuse the Indexer.

header1.h
#ifndef HEADER1_H_
#define HEADER1_H_

typedef struct fred{
	int a;
} fred_t;

#endif /* HEADER1_H_ */

header2.h
I used float so I could tell which was being used when hovering.
I changed the float to int but F3 still goes to the proper header file.
I also tried changing the 'b' to an 'a' and it still worked properly.
#ifndef HEADER2_H_
#define HEADER2_H_

typedef struct fred{
	float b;
} fred_t;

#endif /* HEADER2_H_ */

main.c
#include <stdio.h>
#include <stdlib.h>

#include "header1.h"

int main(void) {
	fred_t * pFred;
	puts("Hello World"); /* prints Hello World */
	return EXIT_SUCCESS;
}
Previous Topic:C / C++ Build properties
Next Topic:Codan problem/bug?
Goto Forum:
  


Current Time: Wed Apr 24 22:14:47 GMT 2024

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

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

Back to the top