delorie.com/archives/browse.cgi | search |
From: | ryot AT bigfoot DOT com (George Ryot) |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: a K-R program doesn't work only with DJGPP |
Message-ID: | <3815421a.4177796@news.clara.net> |
References: | <Pine DOT SUN DOT 3 DOT 91 DOT 991024095838 DOT 29385i-100000 AT is> |
X-Newsreader: | Forte Agent 1.5/32.452 |
X-No-Archive: | yes |
MIME-Version: | 1.0 |
Lines: | 32 |
Date: | Sun, 24 Oct 1999 17:34:08 GMT |
NNTP-Posting-Host: | 195.8.91.64 |
X-Complaints-To: | abuse AT clara DOT net |
X-Trace: | nnrp4.clara.net 940786448 195.8.91.64 (Sun, 24 Oct 1999 18:34:08 BST) |
NNTP-Posting-Date: | Sun, 24 Oct 1999 18:34:08 BST |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote: > > 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. Thanks. It was clear that the different functionality was the cause of the crash but I was not aware this went against the standard. > 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'. As did the original K&R program. So to answer the original poster's question: rename the qsort function (and *every* call to it) to something else and the program will run. It might be worth getting a more up to date book btw ;-) There is a list of C/C++ programming books with reviews at http://www.accu.org -- george
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |