struct comparison

Jeffrey Kegler jeffrey at algor2.uu.net
Tue Jul 25 12:29:49 AEST 1989


In article <2280 at auspex.auspex.com> guy at auspex.auspex.com (Guy Harris) writes:
>>You compare pointer values.
>
>Which may not always correspond to what you want; i.e., "these two
>structure values have the same values in all their fields" may not be
>equivalent to "the objects these structures represent are equal".  If,
>say, experience with Ada indicates that they are frequently equivalent,
>and that people do use structure comparison heavily, that experience
>might, with some care, be applicable to C; otherwise, the right thing to
>do is NOT to put it into the standard, but put it into GCC or some other
>compiler and see how often it's really used. 

Precisely right.  If we were arbitrarily stuck with an untested
interpretation of structure comparison, we might soon regret it.  I
have my guess as the best way to compare structures by default (ignore
unions and padding, compare pointers by value), but any guess that
winds up in the standard we would be stuck with for a long time to
come.

The proper way to lobby for your favorite method of structure
comparison is to hack GCC, and submit it to a jury of our peers.  Just
sticking a best guess into a standard is not a good idea.  The ANSI C
Committee deserves congratulations for having recognized this.
-- 

Jeffrey Kegler, President, Algorists,
jeffrey at algor2.UU.NET or uunet!algor2!jeffrey
1762 Wainwright DR, Reston VA 22090



More information about the Comp.std.c mailing list