Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Indexer equivalent of "gcc --include filename" ?
Indexer equivalent of "gcc --include filename" ? [message #722672] Tue, 06 September 2011 13:27 Go to next message
niels.penneman is currently offline niels.pennemanFriend
Messages: 3
Registered: September 2011
Junior Member
I'm working on a project with a custom Makefile where one global configuration header is included automatically in every invocation of gcc through

gcc --include headerfile.h ... sourcefile.c

This is an alternative to adding '#include "headerfile.h"' to every single C source file.

However, I cannot find a way to let the Eclipse CDT indexer deal with this. Hence, all #ifdef'ed code sections are considered "inactive", errors stack up, and type/call hierarchy is broken. Hence, I have no benefit at all in using Eclipse anymore.

I was hoping to find something in project settings but I can only manually add symbols. As the configuration header changes over time, this is not an option.

I am using Eclipse Indigo. Any suggestions?
Re: Indexer equivalent of "gcc --include filename" ? [message #722982 is a reply to message #722672] Wed, 07 September 2011 11:23 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Open Project Properties->C/C++ General->Indexer
Files to index up-front: add your header here


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Indexer equivalent of "gcc --include filename" ? [message #723001 is a reply to message #722982] Wed, 07 September 2011 12:06 Go to previous messageGo to next message
niels.penneman is currently offline niels.pennemanFriend
Messages: 3
Registered: September 2011
Junior Member
I've tried your suggestion and this leads to an interesting situation:


  • Code sections between "#ifdef CONFIG_BLAH ... #endif" are still shaded even if CONFIG_BLAH is defined in config.h and inside these sections indexing does not work.
  • I can now ctrl+click or use "open declaration" on CONFIG_BLAH and this opens my header file, exactly on the line where it shows "#define CONFIG_BLAH 1"!

Re: Indexer equivalent of "gcc --include filename" ? [message #723269 is a reply to message #723001] Thu, 08 September 2011 08:25 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
niels.penneman wrote on Wed, 07 September 2011 14:06
I've tried your suggestion and this leads to an interesting situation:


  • Code sections between "#ifdef CONFIG_BLAH ... #endif" are still shaded even if CONFIG_BLAH is defined in config.h and inside these sections indexing does not work.
  • I can now ctrl+click or use "open declaration" on CONFIG_BLAH and this opens my header file, exactly on the line where it shows "#define CONFIG_BLAH 1"!


Did you rebuild the index?

Open Project Prpoperties and goto C/C++ General->Paths and Symbols->Symbols tab. Is CONFIG_BLAH listed there? (these are the symbols that are automaticall found when you build your application). Did you add it manually?


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Indexer equivalent of "gcc --include filename" ? [message #723722 is a reply to message #723269] Fri, 09 September 2011 09:14 Go to previous messageGo to next message
niels.penneman is currently offline niels.pennemanFriend
Messages: 3
Registered: September 2011
Junior Member
Yes, I have rebuilt the index.

I've tried with both "${project_loc}/build/config.h" and "build/config.h". The symbols never show up in project properties, but I can click through on the macros as described earlier.
Re: Indexer equivalent of "gcc --include filename" ? [message #724863 is a reply to message #723722] Tue, 13 September 2011 11:27 Go to previous message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Perhaps I have found a better solution for your problem.

- Open project properties
- Select C/C++ Build
- Click on Discovery Options
- At the bottom of the screen where it says Compiler invocation arguments, insert "-include headerfile.h "
- In C/C++ General->Indexer: remove headerfile.h
- build your project

I got these instructions from here http://wiki.eclipse.org/HowTo_use_the_CDT_to_navigate_Linux_kernel_source



Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Previous Topic:printf is ambiguous messages on indigo/CDT 8
Next Topic:Is there a way to cancel the code assist after it's already been activated?
Goto Forum:
  


Current Time: Thu Apr 25 07:29:57 GMT 2024

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

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

Back to the top