[patch] TODO more cleanups

J.T. Conklin jtc@redback.com
Tue Nov 21 10:59:00 GMT 2000


>>>>> "Eli" == Eli Zaretskii <eliz@delorie.com> writes:
>> To expand a little on the comment attatched to STREQ().  The intention
>> is that the person rewriting the STREQ() calls does more than hope that
>> the changes work.

Eli> Can you tell why this is at all a Good Thing?
Eli>
Eli> I've seen projects that argue whether or not to replace strcmp with
Eli> STREQ, but this is the first project that wants to do the opposite...

My take on this is that macros like STREQ() are nothing more than
syntactic sugar.  We don't define macros like:

        #define begin   {
        #define end     }

to make it "easier", and IMO by the same token there's no need to
define macros like STREQ().

I believe the intent is that using them is somehow more error
resistant than calling the underlying function.  I don't have any
evidence to refute this, but it seems to me that it hides the use of a
function which any C programmer should thoroughly grok it's semantics
with a macro that has to be looked up.

And in this case, it's important.  As part of a (dubious, IMO) micro-
optimization, the STR* macros evaluate their arguments multiple times.
If the programmer doesn't know this, and thinks that the STR* macros
are simply conventional sugar, they're likely to write broken code.

        --jtc

-- 
J.T. Conklin
RedBack Networks


More information about the Gdb-patches mailing list