When I run gcov foo.cpp it not only generates the code coverage report for foo.cpp, but for all the STL headers used by foo.cpp.
Is there a way to prevent this? It seems to ignore standard library headers like <ctime>
.
Edit
Just ran across this post on the gcc mailing list:
Re: gcc, gcov and STL
Any C++ header files with inline code will get coverage instrumentation when you compile and the results will be visible with gcov. One useful flag is gcov -long-file-names
(or just -l) which creates a unique .gcov output file for each header included by a given file. The files have names like foo.cpp##bar.h.gcov
. This would make them easy for you to delete afterward with rm \*\\#\\#\*.gcov
(careful with those backslashes!)
Another way you can detect these files is to look for the lines numbered 0 in the gcov output. These have tagged information including 'Source:' with the full path to the original source file.
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