Implement code coverage flush function with boiler plate code
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.