Given a C program, call it temp.c, the following works on Linux and is supposed to work on mac os to show coverage information:
gcc -fprofile-arcs -ftest-coverage temp.c
a.out
gcov temp.c
However when I try it on my macbook pro, running mojave, gcov results in the following error
Unexpected version: *20B. Invalid .gcno File!
my gcc version is gcc version 10.2.0 (Homebrew GCC 10.2.0)
What has happened?
gcov --version
. Is it a GCC version ofgcov
or is it LLVM/clang? I believe he default on MacOS isgcov
built withclang
, have you tried compiling your software usingclang
instead ofgcc
? You could also try to install agcc
basedgcov
on your Mac to see if it works better.