Standard scheme for maintainer-only debugging code?

Nathanael Nerode neroden@twcny.rr.com
Tue Jun 10 04:25:00 GMT 2003


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



More information about the Gcc mailing list