Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How to index all header files in Eclipse CDT on linux?
How to index all header files in Eclipse CDT on linux? [message #1841634] Mon, 24 May 2021 08:02 Go to next message
John Reese is currently offline John ReeseFriend
Messages: 3
Registered: May 2021
Junior Member
I have a C++ project structure like that:

-A
--includes
--- A.h
--source
--- A.cpp

-B
--includes
--- B.h
--source
--- B.cpp

I include "B.h" in A.cpp like " #include <B/B.h> " but it cannot resolve B.h header file. How can i index that header file. I added paths of B.h file but again cannot resolved. Is there an any way to index that header file? or Do i have to include like that " #include <B/includes/B.h> "?
Re: How to index all header files in Eclipse CDT on linux? [message #1841658 is a reply to message #1841634] Tue, 25 May 2021 05:26 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Assuming the "-" indicates a directory level
there is no file named B/B.h
even the compiler won't find it.

But there is one named B/includes/B.h.
The compiler will find it if the project directory is in the include paths.

Note there is a difference between #include <...> and #include "..."
https://stackoverflow.com/a/4932754
http://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html
the latter is specific to GCC.

The Indexer looks for includes pretty much like the compiler
but it searches paths listed in
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros, etc.
A more detailed description:
https://www.eclipse.org/community/eclipse_newsletter/2013/october/article4.php

Note: you have to tell both the compiler and the Indexer what the paths are.

[Updated on: Tue, 25 May 2021 07:18]

Report message to a moderator

Re: How to index all header files in Eclipse CDT on linux? [message #1841749 is a reply to message #1841658] Thu, 27 May 2021 12:46 Go to previous messageGo to next message
John Reese is currently offline John ReeseFriend
Messages: 3
Registered: May 2021
Junior Member
Actually, I dont understand that header file in A/includes/A.h can be find from A/source/A.cpp file when I include it like " #include <A/A.h> ". I don't need to add "includes/ " to the path. However, it cannot find B.h header file when I include it like " #include <B/B.h>

Also, i added header files and paths of header files (paths: B/includes/ and B) to Project --> Properties --> C/C++ General --> Paths and Symbols section. Again, it cannot find that header file in B/includes/B.h from A/source/A.cpp when I include it like " #include <B/B.h> ".
I am using MinGW Gcc toolchain.
Re: How to index all header files in Eclipse CDT on linux? [message #1841762 is a reply to message #1841749] Fri, 28 May 2021 02:10 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Quote:
Actually, I don't understand that header file in A/includes/A.h can be find from A/source/A.cpp file when I include it like " #include <A/A.h> ". I don't need to add "includes/ " to the path.


I don't understand it either. A/A.h doesn't exist if what you've told us is correct.

What you should add to Paths and Symbols is A/includes and B/includes
as absolute paths
and use #include <A.h> and #include <B.h>

OR,
put your project directory in Paths and Symbols and use
#include <A/includes/A.h>
#include <B/includes/B.h>

OR,
put A and B (recommend absolute paths) in Paths and Symbols and use
#include <includes/A.h>
#include <includes/B.h>

The key is that whatever is in the include (e.g., #include <X>)
has to be a legitimate file when prepending one of the include directories
That is, <some path on include path list>/X

You can have relative paths on the list
but be aware they are relative to the current directory.
The indexer and compiler are unlikely to be using the same current directory.

You also need to turn on the Managed Build settings provider after adding them.
Paths and Symbols is a shortcut to inform both the compiler and the Indexer
but the Indexer only uses the directories found in
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros, etc.
You need the Managed Build settings provider to get them on the list.

[Updated on: Sun, 30 May 2021 08:07]

Report message to a moderator

Re: How to index all header files in Eclipse CDT on linux? [message #1841828 is a reply to message #1841762] Mon, 31 May 2021 13:10 Go to previous message
John Reese is currently offline John ReeseFriend
Messages: 3
Registered: May 2021
Junior Member
Thanks a lot for your solutions.
Previous Topic:Preserve whitespace between code and comment doesn't?
Next Topic:Error in final launch sequence: Failed to execute MI command: -exec-run
Goto Forum:
  


Current Time: Fri Apr 19 21:51:03 GMT 2024

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

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

Back to the top