GCOV: What is the difference between --coverage and --ftest-coverage when building with GCC?

user3338893 picture user3338893 · Mar 3, 2015 · Viewed 13.6k times · Source

Trying to get code coverage up and running, and I'm just reading documentation first. I found a few articles that mention building with the --coverage flag, while others mention the --ftest-coverage.

Both descriptions seem to say they do the same thing, but I'm not certain.


Here's two articles:


What's the difference?

Answer

sigy picture sigy · Dec 6, 2016

As already stated in the comments --coverage is a synonym for other flags related to code coverage depending on the context.

3.11 Program Instrumentation Options:

--coverage

This option is used to compile and link code instrumented for coverage analysis. The option is a synonym for -fprofile-arcs -ftest-coverage (when compiling) and -lgcov (when linking).