Niko Z.
Niko Z.

Reputation: 352

Is there any macro defined when compiling with --coverage option?

As mentioned by the title, I would like to achieve something like this:

void my_exit(int status)
{
#ifdef _GCOV
   __gcov_flush();
#endif
   _exit(status);
}

But I do not know if there is a _GCOV(or something similar) defined when compiling with --coverage. Any idea will be appreciated!

Upvotes: 3

Views: 684

Answers (2)

eerorika
eerorika

Reputation: 238351

Since there appears to not be a pre-defined macro, as per o11c's answer, a simple solution is to define it yourself:

gcc --coverage -D GCOV

Upvotes: 3

o11c
o11c

Reputation: 16056

Doesn't seem to be:

$ true | gcc -E - -dM > no-coverage.h
$ true | gcc -E - -dM --coverage > coverage.h
$ diff no-coverage.h coverage.h 

Upvotes: 3

Related Questions