Implement code coverage flush function with boiler plate code In each shared library that I build, it need to call __gcov_flush but that call should only be made when building the instrumented binaries for code review. 
In that case I'm passing  

-D__CODE_COVERAGE__

option as a compilation flag.

And in each .so file.

#ifdef __CODE_COVERAGE__

void cscomm_gcov_flush()
{
    __gcov_flush();
}
#endif // __CODE_COVERAGE__


So I'm keeping the same source tree for both code coverage , debug and release.
Is this approach is oky, good or bad ? Can you review?
This works (at least I assume it does), but it's not how I'd do things.

I'd put the code:

void cscomm_gcov_flush()
{
    __gcov_flush();
}


...into a file by itself (e.g., flusher.c or flusher.cc, as you prefer). Then I'd have the build tool decide whether to compile and link that into the .so files depending on whether it's building an instrumented binary or not.

OBJS = // file list here

ifdef __CODE_COVERAGE__
    OBJS += flusher.o
endif


Syntax varies with the build tool you're using of course, but I think the general idea is fairly apparent.

Looking at the code more generally, names that start with an underscore followed by another underscore or a capital letter (including __CODE_COVERAGE__) are all reserved for the implementation, so defining them leads to undefined behavior. If the compiler does it in response to a command line argument (or similar) that's fine, but if you're doing it yourself, you have undefined behavior.