[GRASS5] Status of 5.0.0 release

Justin Hickey jhickey at hpcc.nectec.or.th
Wed Apr 18 06:58:30 EDT 2001


Hello all

Glynn Clements wrote:
> 
> Michel Wurtz wrote:
> 
> > > > Do you want the qsort() warnings fixed? AFAICT, all of these 
> > > > arise from comparison functions taking pointers to the actual
> > > > object type, but qsort() having a fixed prototype with a fixed
> > > > 4th parameter.
> > > >
> > > > Fixing them is basically a choice of either:
> > > >
> > > > a) changing e.g.:
> > > >
> > > >       int compare(foo *a, foo *b)
> > > >       {
> > > >               return CMP(*a, *b);
> > > >       }
> > > > to
> > > >       int compare(void *aa, void *bb)
> > > >       {
> > > >               foo *a = (foo*) aa;
> > > >               foo *b = (foo*) bb;
> > > >               return CMP(*a, *b);
> > > >       }
> > > >
> > > > or:
> > > >
> > > > b) explicitly casting the 4th argument to qsort()
> > [...]
> > I like a compile process without warning... 

So do I.

> > The b) solution seems  easier, and probably more understandable
> > (even more with a comment line ;-), but does it really suppress
> > warnings ?
> 
> Good point. IIRC, casting function pointers (either explicitly or
> implicitly) isn't 100% legal.
> 
> Also, many people seem to have problems reading function types 
> (Linux' signal(2) manpage even includes an explanation of how to read
> the declaration of the second parameter).

The a) option is the correct way to fix this. The compare function
should take void pointers as parameters and cast them to the proper type
inside the function. I consider the b) option a hack. But that's just my
opinion.

-- 
Sincerely,

Jazzman (a.k.a. Justin Hickey)  e-mail: jhickey at hpcc.nectec.or.th
High Performance Computing Center
National Electronics and Computer Technology Center (NECTEC)
Bangkok, Thailand
==================================================================
People who think they know everything are very irritating to those
of us who do.  ---Anonymous

Jazz and Trek Rule!!!
==================================================================

---------------------------------------- 
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo at geog.uni-hannover.de with
subject 'unsubscribe grass5'



More information about the grass-dev mailing list