delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/24/09:31:26

Date: Sun, 24 Oct 1999 09:58:58 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: George Ryot <ryot AT bigfoot DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: a K-R program doesn't work only with DJGPP
In-Reply-To: <3815f2df.20207061@news.clara.net>
Message-ID: <Pine.SUN.3.91.991024095838.29385i-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Fri, 22 Oct 1999, George Ryot wrote:

> The DJGPP startup code calls the globbing function which in turn calls
> qsort which has been redefined to do something bad.

That's correct; the startup code sorts the globbed wildcards, if any,
into alphabetical order.

> Whether this is a program or compiler bug hinges on whether or not it
> is legal to have user defined functions which overide those in libc.
> 
> I am fairly sure that it is, and so this is indeed a DJGPP bug.

The ANSI C Standard permits to supply your own versions of library
functions, but only if the substitute has the same interface and
functionality as the original.

In particular, the Standard says that any standard C function (`qsort'
is one of them) has an ``external linkage'', and that any declaration
you write for such a function must agree in type and meaning with the
definition provided by the compiler (in this case, the
compiler-provided definition is in the header stdlib.h).

Your example violates this requirement by providing an incompatible
definition of `qsort'.

- Raw text -


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