Article View: comp.std.c++
Article #3182Re: When can definitions of library functions be provided by a program?
From: James Kanze US/ESC 60/3/141 #407...
Date: Thu, 01 Feb 1996 16:35
Date: Thu, 01 Feb 1996 16:35
48 lines
2890 bytes
2890 bytes
In article <DM2Bv9.C7p@scr.siemens.com> mlg@scr.siemens.com (Michael
Greenberg) writes:
|> I'm trying to figure out under what circumstances a program can supply
|> a definition for a library function. Is it the case that a program
|> cannot supply a definition for any library function except for those
|> listed in 17.3.3.4 (new & delete with various signatures)?
The only library functions that the user can replace are those where
it says explicitly that they can be replaced: operator new, operator
delete, unexpected and terminate.
[ Moderator's note: Michael Greenberg is correct: only new and ]
[ delete can be replaced. The user is not allowed to supply ]
[ definitions for unexpected() and terminate(), although a ]
[ similar effect can be obtained by calling set_unexpected() and ]
[ set_terminate(). -fjh. ]
|> In other words (typos not withstanding), is
|> #include <string.h>
|> int std::strlen(const char*) { ... }
|> legal? What if <string.h> is not included?
Illegal, with or without string.h.
|> (As an aside, what's the 'C' standard have to say about this?)
Basically the same thing, except that there are no user replaceable
functions. The compiler is allowed to know the semantics of all of
the library functions (and the restrictions concerning the semantics
of the replaceable functions), and take advantage of them in its
optimizations. (The most obvious case: the compiler knows that none
of these functions access any of your global variables, so it may
maintain the global variables in a register accross calls to the
function. I have already used a C compiler that did this.)
--
James Kanze Tel.: (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils, itudes et rialisations en logiciel orienti objet --
-- A la recherche d'une activiti dans une region francophone
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<9602011318.AA07436@lts.sel.alcatel.de>Path:
arc1-ca.pugleaf.net!in1.uu.net!bounce-backReferences:
<DM2Bv9.C7p@scr.siemens.com>Show Full Headers
Complete Article Headers
From: James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> Message-ID: <9602011318.AA07436@lts.sel.alcatel.de> X-Original-Date: Thu, 1 Feb 96 14:18:32 +0100 Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back Date: 01 Feb 96 16:35:02 GMT Approved: fjh@cs.mu.oz.au Organization: - In-Reply-To: mlg@scr.siemens.com's message of 31 Jan 1996 20:44:58 GMT Newsgroups: comp.std.c++ Subject: Re: When can definitions of library functions be provided by a program? References: <DM2Bv9.C7p@scr.siemens.com> X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMRDt1+EDnX0m9pzZAQHdtAGAizHikd+urmXuE2LQi7gzoX/YN9Mxohj1 7TfXNn8JxsImYBTmpHPjXcwFKbd+CQ+y =ZM/r