Subject: Re: qsort problems
To: None <wulf@ping.net.au>
From: Mike Long <mike.long@analog.com>
List: netbsd-help
Date: 11/07/1996 15:05:59
>From: Berndt Josef Wulf <wulf@ping.net.au>
>Date: Thu, 7 Nov 1996 17:57:53 +1030 (CST)

>I have problems with qsort as long as I can think of when trying to
>built packages which utilize this function. On building the package I
>get the following warning message:

>utmp.c:229: warning: passing arg 4 of `qsort' from incompatible
>pointer type
>
>This line looks like this:
>
>qsort( (void *)l_array, (size_t)count, sizeof(TTY_NODE *), comparison);
>
>Argument 4 in this function is defined as followed:
>
>int comparison( TTY_NODE **arg1, TTY_NODE **arg2 )

>void
>qsort(void *base, size_t nmemb, size_t size,
>int (*compar)(const void *, const void *))

The system expects that the fourth argument to qsort() is of the type:

int (*)(void *, void *)

You are passing it an argument of the type:

int (*)(TTY_NODE **, TTY_NODE **)

The difference in the passed function's arguments is why you get the
incompatible pointer type message.  The comparison function used by
the package needs to be redefined to accept (void *) arguments instead
of (TTY_NODE **) arguments.
-- 
Mike Long <mike.long@analog.com>     <URL:http://www.shore.net/~mikel>
VLSI Design Engineer         finger mikel@shore.net for PGP public key
Analog Devices, CPD Division          CCBF225E7D3F7ECB2C8F7ABB15D9BE7B
Norwood, MA 02062 USA       (eq (opinion 'ADI) (opinion 'mike)) -> nil