coveragepy icon indicating copy to clipboard operation
coveragepy copied to clipboard

Compiler warning when compiling with GCC -Wundef

Open edmundsj opened this issue 2 years ago • 1 comments

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_LOG
  • WHAT_LOG
  • DO_NOTHING

To Reproduce How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:

  1. What version of Python are you using? 3.8
  2. What version of coverage.py shows the problem? The output of coverage debug sys is helpful. 5.4 and master
  3. What versions of what packages do you have installed? The output of pip freeze is helpful. Not possible :p
  4. 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
  5. 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.

edmundsj avatar Oct 09 '23 21:10 edmundsj

I'm not sure how to provide that flag. How did you do it, so I can be sure to have it right?

nedbat avatar Oct 10 '23 21:10 nedbat