gcov is not generating coverage information for header files

后端 未结 3 1920
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-21 14:19

I\'m using gcov for the first time and I\'m having a problem which is similar to the one reported in this thread. However, I wasn\'t able to solve my problem following the comme

3条回答
  •  没有蜡笔的小新
    2021-01-21 14:58

    I want to complete the answer that I gave to @Klaus.

    Both combinations "-O2 -g" and "-O2" gives the following coverage information for this method (I inserted the message only to be sure that the method was being executed in the tests):

    -:  192:  const QString& institutionId(void) const {
    1:  193:    std::cout << "Inside institutionId\n";
    -:  194:    return m_institution;
    -:  195:  }
    

    That means that the lines 192 and 194 are not considered as executable, but only the cout. The flag -g does not affect the result (at least in this case).

    If I build the program using "-O0", the result is:

    1:  192:  const QString& institutionId(void) const {
    1:  193:    std::cout << "Inside institutionId\n";
    1:  194:    return m_institution;
    -:  195:  }
    

提交回复
热议问题