Reputation: 345
I instrument my productive code with the flags -fprofile-arcs
and -ftest-coverage
, then I test this code with unit tests. For the unit tests to compile and run, I am forced to make some fakes and mocks.
I can control during compilation which cpp files are instrumented and which ones are not. But, when compiling my productive code with flags for instrumentation, the code for the fakes and mocks will also be included through the header files.
Is there a way to avoid instrumenting the header files included in the cpp files?, for example using some attribute, pre processor directive or compilation flag.
Upvotes: 2
Views: 529
Reputation: 11
You can use the function attribute no_instrument_function to suppress profiling of individual functions when compiling with instrumenting options.
see: https://gcc.gnu.org/onlinedocs/gcc-9.3.0/gcc/Instrumentation-Options.html https://gcc.gnu.org/onlinedocs/gcc-9.3.0/gcc/Common-Function-Attributes.html#Common-Function-Attributes
Upvotes: 1
Reputation: 8851
No, there should be no way. What #include
does is actually putting content inside cpp file before its compilation.
Upvotes: 1