C and C++ Unused Headers
Wasting a lot of time trying to figure out what headers you need to keep in your #include? Going file by file, and you only have 2,000 files to go...
Download and install this Understand Script and you will be able to see what headers are needed, and which one you can remove.
Script requires a valid version of SciTools Understand.
Output Example (abcdmathfunction.cpp part of Open Source Quanlib++)
You DIRECTLY include the following headers:
blackcallablebondengine.hpp : 1X : .\QUANTLIB\QuantLib1.19\ql\experimental\callablebonds\blackcallablebondengine.hpp
callablebond.hpp : 2X : .\QUANTLIB\QuantLib1.19\ql\experimental\callablebonds\callablebond.hpp
cashflowvectors.hpp : 1X : .\QUANTLIB\QuantLib1.19\ql\cashflows\cashflowvectors.hpp
zerospreadedtermstructure.hpp : 1X : .\QUANTLIB\QuantLib1.19\ql\termstructures\yield\zerospreadedtermstructure.hpp
brent.hpp : 1X : .\QUANTLIB\QuantLib1.19\ql\math\solvers1d\brent.hpp
These are including IMPLICITELY by others:
any.hpp : 2X : .\BOOST.1.74\boost_1_74_0\boost\any.hpp
function.hpp : 1X : .\BOOST.1.74\boost_1_74_0\boost\function.hpp
enable_shared_from_this.hpp : 5X : .\BOOST.1.74\boost_1_74_0\boost\enable_shared_from_this.hpp
make_shared.hpp : 5X : .\BOOST.1.74\boost_1_74_0\boost\make_shared.hpp
shared_ptr.hpp : 5X : .\BOOST.1.74\boost_1_74_0\boost\shared_ptr.hpp
assert.hpp : 5X : .\BOOST.1.74\boost_1_74_0\boost\assert.hpp
current_function.hpp : 5X : .\BOOST.1.74\boost_1_74_0\boost\current_function.hpp
exception : 5X : C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\include\exception
bind.hpp : 1X : .\BOOST.1.74\boost_1_74_0\boost\bind\bind.hpp
ref.hpp : 1X : .\BOOST.1.74\boost_1_74_0\boost\ref.hpp
<...>
These are NEEDED (they are used as direct references)
interpolation.hpp : .\QUANTLIB\QuantLib1.19\ql\math\interpolation.hpp
timeseries.hpp : .\QUANTLIB\QuantLib1.19\ql\timeseries.hpp
currency.hpp : .\QUANTLIB\QuantLib1.19\ql\currency.hpp
shared_ptr.hpp : .\QUANTLIB\QuantLib1.19\ql\shared_ptr.hpp
<...>
These, I can't decide. They are mostly headers that are not part of the analysis, so I can't tell.
any.hpp : .\BOOST.1.74\boost_1_74_0\boost\any.hpp
function.hpp : .\BOOST.1.74\boost_1_74_0\boost\function.hpp
enable_shared_from_this.hpp : .\BOOST.1.74\boost_1_74_0\boost\enable_shared_from_this.hpp
make_shared.hpp : .\BOOST.1.74\boost_1_74_0\boost\make_shared.hpp
shared_ptr.hpp : .\BOOST.1.74\boost_1_74_0\boost\shared_ptr.hpp
<...>
These are >> NOT << NEEDED (they aren't used)
userconfig.hpp : .\QUANTLIB\QuantLib1.19\ql\userconfig.hpp
config.ansi.hpp : .\QUANTLIB\QuantLib1.19\ql\config.ansi.hpp
mathconstants.hpp : .\QUANTLIB\QuantLib1.19\ql\mathconstants.hpp
qldefines.hpp : .\QUANTLIB\QuantLib1.19\ql\qldefines.hpp
<...>
SUGGESTED SOLUTION:
You will include the following:
cashflowvectors.hpp which would include cmath timeseries.hpp set <...>
blackcallablebondengine.hpp which would include instrument.hpp volatilitytype.hpp <...>
brent.hpp which would include solver1d.hpp iomanip curiouslyrecurring.hpp
<...>
Summary:
blackcallablebondengine.hpp : .\QUANTLIB\QuantLib1.19\ql\experimental\callablebonds\blackcallablebondengine.hpp
cashflowvectors.hpp : .\QUANTLIB\QuantLib1.19\ql\cashflows\cashflowvectors.hpp
zerospreadedtermstructure.hpp : .\QUANTLIB\QuantLib1.19\ql\termstructures\yield\zerospreadedtermstructure.hpp
brent.hpp : .\QUANTLIB\QuantLib1.19\ql\math\solvers1d\brent.hpp