This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Standard scheme for maintainer-only debugging code?
- From: Nathanael Nerode <neroden at twcny dot rr dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 10 Jun 2003 00:18:52 -0400
- Subject: Standard scheme for maintainer-only debugging code?
I was looking at the *great* *mass* of #if 0 sections scattered
throughout GCC, and noticed that a some of them were clearly
designed to give information to the maintainers of the file while the
program was running.
We should have a consistent scheme for such things, rather than loading
the code with #if 0, commented-out code, #if MY_FAVORITE_MACRO, and so
forth.
(Or should we just kill all of these hunks outright?)
What looks good?
If we're willing to assume that if (0) will be optimized away,
how about:
if ( MAINTAINER_DIAGNOSTICS("my_topic") ) {...}
where MAINTAINER DIAGNOSTICS is normally defined to 0 always, by
#define MAINTAINER_DIAGNOSTICS(x) (0)
but maintainers could define it however they want for debugging
purposes; perhaps like this:
#define MAINTAINER_DIAGNOSTICS(x) !strcmp((char*)&"my_topic",(char*)&x)
I can imagine better ways of defining it. The point is that having one
guard for such things would be a Good Thing. Anyone else agree?
--Nathanael