Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse CDT - shortcut to know which all files include a header file?

I have a big project. I want to find which all .cpp/.h files include file1.h in them. Is there any shortcut key in Eclipse CDT to do this?

like image 456
Vivek V K Avatar asked Mar 28 '15 05:03

Vivek V K


People also ask

How do you check if a header file is included?

To check if an header file has been included or not in a C or C++ code, we need to check if the macro defined in the header file is being defined in the client code. Standard header files like math. h have their own unique macro (like _MATH_H ) which we need to check. Consider this example of checking if math.

Where does C look for include files?

GCC looks for headers requested with #include " file " first in the directory containing the current file, then in the directories as specified by -iquote options, then in the same places it would have looked for a header requested with angle brackets.

In which section of C program header files are included?

You have to stdio. h header file in each and every C program code. The <stdio. h> header file is used for standard input and output operations such as reading data from the user using scanf() function and printing output on the screen using printf() function.

HOW include header file in C Eclipse?

Select C/C++ General -> Path and Symbols. Select Includes tab. In Languages list, select 'GNU C' or whatever C compiler tool chain you use. Press 'Add...' button and add the directory for the include files.


2 Answers

I'd suggest the Include Browser view. You can drag a file in there and you get a nice tree which shows all files that include your file, including indirect includes.

like image 167
Paul Omta Avatar answered Sep 28 '22 07:09

Paul Omta


In Eclipse, under the search menu, the entry File... exists. Searching there for #include*"file1.h" should do the trick.

Optimization suggestions: Preferences->General->Keys, search for file search then add the binding Ctrl+H for it. This is by default mapped to C/C++ Search, so you will have to remove the prior binding or use another hotkey.

If you want to go the extra mile, check out Practically Macro. It should be straight forward to make a "Search including files" macro with it.

like image 20
a3f Avatar answered Sep 28 '22 09:09

a3f