0

I'm searching for a tool to get the used header (if there is one/more) for every line/statment in my c++ code.

Example:

#include<iostream> 
std::cout << "hallo";

The output i'd like to see:

line 2: std::cout uses "iostream"

I found this question, the tools there do most of the part, they show dependency per file.

Does anyone know such a tool or how to acomplish this with the tools given in the answers in the question above?

Goal: I'm checking code for the conformity to a standard which i have a list of allowed headers for. With the desired output I can create a metric saying something like: 60% of the code is using allowed headers, 15% is using other headers or something like that.

lleo
  • 155
  • 1
  • 9
  • 2
    This question is explicitly off-topic on stackoverflow. You may have some luck [here](https://softwarerecs.stackexchange.com/). – nwp Jan 15 '18 at 15:27
  • 2
    You can use include-what-you-use for that with big verbosity – R2RT Jan 15 '18 at 15:29

2 Answers2

1

This is not completely what you want but you can use Eclipse CDT to know where std::cout is declared.

If you press F3 when cout is selected in Eclipse, you will jump to this line of code inside iostream header file on the system with gcc 7:

  extern ostream cout;      /// Linked to standard output
ks1322
  • 33,961
  • 14
  • 109
  • 164
  • Thanks! That and the gcc -M flag are the way I'm doing it right now, but I'm searching for a more overall automated version. I added my goal to the question – lleo Jan 15 '18 at 16:59
1

You can try CppDepend to get all the methods called by a specific one with the location of each method called.

enter image description here