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?
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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With