sh*****@gmail.c om wrote:
I have overloaded new in a shared library (s1.so) sucessfully. but I
do not what main program and any other shared library to be able to
use this new operator. In other words, I do not operator new to be
globally used.
I tried some ld options -Bsymbolic as follows
g++ -shared -Wl,-Bysmbolic f1.o -o s1.so
g++ -lstdc++ main.o s1.so -o main
However, if I put -lstdc++ after s1.so, the overloaded new being used
by main (which is not what I want )
Any comments?
For compiler- and platform- specific questions please ask in the newsgroups
for that compiler or that platform. "Shared library" is a concept undefined
in C++. "ld options" is specific to your compiler and/or platform.
Usually, a way to limit the use of the overloaded operator 'new' is to give
it an additional argument, similar to
// header
class my_new_identifi er {}; // just some unique type
extern my_new_identifi er mynew;
// implementation
my_new_identifi er mynew;
void* operator new(size_t howmuch, my_new_identifi er&) {
... // same as before
}
// somewhere in the code
SomeClass* ptr = new SomeClass(args) ; // regular 'new'
SomeClass* ptr2 = new (mynew) SomeClass(args) ; // your 'new'
Well, you get the idea. Disclaimer: I didn't test this.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask