coveragepy
coveragepy copied to clipboard
Compiler warning when compiling with GCC -Wundef
Describe the bug
When compiling the C dependencies using GCC with the -Wundef flag, coverage/ctracer/stats.h and coverage/ctracer/tracer.c throw warnings, as the following are potentially or actually undefined:
COLLECT_STATS(stats.h)TRACE_LOGWHAT_LOGDO_NOTHING
To Reproduce How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:
- What version of Python are you using? 3.8
- What version of coverage.py shows the problem? The output of
coverage debug sysis helpful. 5.4 andmaster - What versions of what packages do you have installed? The output of
pip freezeis helpful. Not possible :p - What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix.
master - What commands should we run to reproduce the problem? Be specific. Include everything, even
git clone,pip install, and so on. Explain like we're five!
Expected behavior
The compiler should not throw errors when run with the -Wundef flag.
Additional context
To fix, simply change each of the references to:
#if defined(COLLECT_STATS) && COLLECT_STATS
Or, if there is a more elegant solution involving #ifndef / #define, please do that.
I'm happy to throw up a PR that does this if there is no more elegant solution to the problem.
I'm not sure how to provide that flag. How did you do it, so I can be sure to have it right?