code coverage in C for Mac
gcov is GNU's tool for code coverage. It makes use of graph files (.gcno files) generated when compiled with the -coverage option. However, this option does not exist for Apple's llvm-gcc compiler which means that .gcno files cannot be generated. To solve this, compile exactly the same way but with clang instead of llvm-gcc to generate the graph file. Do something like this:
clang -coverage test.c
./a.out
gcov test.c
You should see the coverage data printed via stdout.
Written by Mihir Pandya
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#