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


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.

  • If all you want is a metric saying "this file uses unallowed headers", why do you need a line-by-line analysis? (I say that because tracking lines through name resolution is a fair amount of work, if you already have a working C++ name resolver)
    – Ira Baxter
    Jan 28, 2018 at 23:31
  • Another way is simply to remove/rename the forbidden files and se where the build falls over :-) Did you find a tool to do what you ask? I would like that too
    – Mawg
    Nov 13, 2018 at 11:03

1 Answer 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

  • From $99 per seat
    – Mawg
    Apr 12, 2019 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.