title: Ignore or exclude code in external libraries with gcov
body: <p>I am working on a project which uses a couple of boost libraries. When looking at our test reports, we have seen that test coverage information sometimes does fit to our source code. I was able to track it down to boost::range. I think it is because of some static initialization inside the library, although I cannot say anything more specific.</p>
  
  <p>Basically, if you compile the following code with <code>gcc --coverage</code>, run it and print the coverage report with <code>gcov -b</code>, there will be four additional branches and an additional line, which I would like to ignore.</p>
  
  <pre><code>#include &lt;boost/range.hpp&gt;
  
  int foo(int x)
  {
      return x+1;
  }
  
  int main(int argc, char* argv[])
  {
      return foo(argc);
  }
  </code></pre>
  
  <p>The coverage report is:
  Lines executed:100.00% of 5
  Branches executed:100.00% of 4
  Taken at least once:50.00% of 4
  Calls executed:100.00% of 2
  Creating 'test_gcov.cpp.gcov'</p>
  
  <p>I guess that the count of 5 lines comes from the two function signatures, the function bodies and one additional line in the boost::range library. I don't know where exactly, but the generated gcov-file shows that some static initialization is going on, so I guess that is where the branches are located.</p>
  
  <p>I would like to know if there is a way to tell gcov to ignore any code in the boost namespace, or any other means.</p>