www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/02/08/12:42:45

From: "Ben Peddell" <lightspeed85 AT hotmail DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <200302081532 DOT h18FW3u24717 AT speedy DOT ludd DOT luth DOT se> <%C91a.6723$kz5 DOT 677340 AT news1 DOT east DOT cox DOT net>
Subject: Re: GCC warning - incompatible pointer type
Lines: 54
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Message-ID: <bea1a.43464$jM5.109474@newsfeeds.bigpond.com>
Date: Sun, 9 Feb 2003 02:38:33 +1000
NNTP-Posting-Host: 144.134.89.95
X-Trace: newsfeeds.bigpond.com 1044721671 144.134.89.95 (Sun, 09 Feb 2003 03:27:51 EST)
NNTP-Posting-Date: Sun, 09 Feb 2003 03:27:51 EST
Organization: Telstra BigPond Internet Services (http://www.bigpond.com)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Do you have RHIDE?
If you do, then press F1, then press Ctrl-G, then type (libc). Click on the
Alphabetical List, then press q. qsort should be the first (and only)
function under q. Then, press enter. Scroll down to the bottom.

Here's the example he was talking about:

======== start of cut-and-paste
Example
-------

     typedef struct {
       int size;
       int sequence;
     } Item;

     int qsort_helper_by_size(const void *e1, const void *e2)
     {
       return ((const Item *)e2)->size - ((const Item *)e1)->size;
     }

     Item list[100];

     qsort(list, 100, sizeof(Item), qsort_helper_by_size);

     int qsort_stringlist(const void *e1, const void *e2)
     {
       return strcmp(*(char **)e1, *(char **)e2);
     }

     char *slist[10];

     /* alphabetical order */
     qsort(slist, 10, sizeof(char *), qsort_stringlist);
====== end of cut-and-paste



Jason Kircher <cdrradar AT hold DOT odiferous DOT titilating DOT mail DOT com> wrote in message
news:%C91a.6723$kz5 DOT 677340 AT news1 DOT east DOT cox DOT net...
> ams AT ludd DOT luth DOT se wrote:
> > Why don't you "info libc a qsort" and see how the example solves this?
> >
> > Alternatively is should be a safe to use strcmp directly (but don't
> > hold me to this in court), so a functioncast (if possible) would make
> > the compiler quiet.
>
> info...  eeech.  All I got out of info was a copy of the man page.  I
> found qsort in the man pages, but without example.  I figured out the
> present usage through (you'll love this) "grep --recursive qsort /*.c"
> I'd love a library reference that HAD examples, or I wouldn't be bald now.
>


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019