admin管理员组文章数量:1278918
I want to test code coverage of my tests over library L.
Let L::foo() be a function in L that I do not use in my tests.
Therefore the object code of foo() is removed/opted out I think by the linker and is not be part of the test application.
So I end up with higher code coverage and cannot see that foo() is not covered.
I think there is a linker flag that forces linker to include even unused code, or perhaps I can do something else while running code coverage. Anyone knows how to do this?
I am using GCC, gcov on Linux.
I want to test code coverage of my tests over library L.
Let L::foo() be a function in L that I do not use in my tests.
Therefore the object code of foo() is removed/opted out I think by the linker and is not be part of the test application.
So I end up with higher code coverage and cannot see that foo() is not covered.
I think there is a linker flag that forces linker to include even unused code, or perhaps I can do something else while running code coverage. Anyone knows how to do this?
I am using GCC, gcov on Linux.
Share Improve this question edited Feb 25 at 12:43 dwto asked Feb 24 at 23:36 dwtodwto 8054 silver badges11 bronze badges1 Answer
Reset to default 0In general you need to remove -Wl,--gc-sections
and add -fkeep-static-functions
in your coverage build.
本文标签: cHow to prevent unused functions from being opted out by linkercompilerStack Overflow
版权声明:本文标题:c++ - How to prevent unused functions from being opted out by linkercompiler? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741236060a2363034.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论