I am using lcov/gcov to measure test coverages in a project.
However, the test coverage report includes some lines signaled as unhitted that shouldn't be there. For example:
Comment lines, function definitions splitted across two lines, opening brackets, etc are counted towards total coverage as not covered.
How can I instruct lcov/gcov to ignore such lines?
Finally, I solved the issue. Looking at gcov man page (https://linux.die.net/man/1/gcov) I found that gcov works only on code compiled with GCC . It is not compatible with any other profiling or test coverage mechanism.
Default C compiler in my system was ClangC. Setting gcc
as compiler when calling cmake
this way
$ cmake . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/gcc
solved the problem.