0

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?

2
  • Check the output of gcov --version. Is it a GCC version of gcov or is it LLVM/clang? I believe he default on MacOS is gcov built with clang, have you tried compiling your software using clang instead of gcc? You could also try to install a gcc based gcov on your Mac to see if it works better. Jan 7, 2021 at 17:09
  • @GracefulRestart You were right to suspect the version of gcov in that it was the clang version, not the gcc version. Unfortunately however compiling with clang did not fix the problem; it just changed the error message to "Unexpected version: *804. Invalid .gcno File!". There still might be a version mismatch since the gcov version is shown as [Apple LLVM version 11.0.0 (clang-1100.0.33.17)] whereas the clang version is shown as 11.0.0. I'm not sure if these are the same since gcov shows clang with a lot longer version string. Jan 7, 2021 at 22:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.