1

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.

2
  • 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 Nov 13, 2018 at 11:03

1 Answer 1

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

1

Your Answer

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

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