Thread View: comp.std.c++
2 messages
2 total messages
Started by bnr (n.) postmaster
Sun, 29 Oct 1995 21:59
[Q] Merging identical functions
Author: bnr (n.) postmaster
Date: Sun, 29 Oct 1995 21:59
Date: Sun, 29 Oct 1995 21:59
18 lines
1329 bytes
1329 bytes
I'm running into problems because a package I use under C++ defines
the same "inline void* operator new(size_t, void* p) { return p; }" as
the STL does.
Is there anything in the C++ standard that will allow identical
definitions such as this to be merged? It seems that, especially with
the above case, such conflicts are likely to be common.
Brian
( bcwhite@bnr.ca )
-------------------------------------------------------------------------------
In theory, theory and practice are the same. In practice, they're not.
[ 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. ]
Re: [Q] Merging identical functions
Author: Steve Clamage
Date: Sun, 29 Oct 1995 23:28
Date: Sun, 29 Oct 1995 23:28
40 lines
2344 bytes
2344 bytes
In article it6@engnews1.eng.sun.com, "bnr (n.) postmaster" <postmast@bnr.ca> writes:
>
>I'm running into problems because a package I use under C++ defines
>the same "inline void* operator new(size_t, void* p) { return p; }" as
>the STL does.
>
>Is there anything in the C++ standard that will allow identical
>definitions such as this to be merged? It seems that, especially with
>the above case, such conflicts are likely to be common.
That should not be a problem for a standard-conforming program, on several
counts.
That version of operator new, among others, is found in standard header <new>,
and probably should not be defined in third-party headers.
Second, real STL is part of the C++ standard library, and all of its
declarations are in namespace <std> (along with the versions of
operator new).
Third, future third-party libraries should not have any global declarations
at all, but place everything in a namespace. That will eliminate name
conflicts entirely, or rather reduce them to the conflict only of namespace
names.
I realize that we are in a transition period, and namespaces are not yet
widely available. Even if your compiler supports them, it will be a while
before third-party libraries use them routinely.
But for this specific case, I would expect that version of operator new
to be found in your compiler's <new.h> header, and so should be removed from
both the version of STL that you are using, and from the header file for
the other package.
---
Steve Clamage, stephen.clamage@eng.sun.com
[ 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. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads