Date: Sun, 24 Oct 1999 09:58:58 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: George Ryot 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: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk 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'.