473,804 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

overload new in shared library (crazy)

Hi

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?

thanks
yan

Apr 18 '06 #1
2 3093
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
Apr 18 '06 #2
gcc has an option for controlling symbol visibility.
You need to declare your overloaded function with
__attribute__ ((visibility("h idden")))
My gcc compiler is not yet configured to use the "visibility " option and
I couldn't try it out.
good luck.
-Aman.

--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Apr 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4425
by: AH | last post by:
I have two functions in my shared library which are declared as follows: void setName(const std::string& str); std::vector<std::string> getInfo(); Since the code is compiled and in shared library. Every thing is great if the customer of my shared library is using the same compiler version (and same STL version). I am wondering if the customer changes their compiler version (or STL version) which may have same interface
5
2081
by: bsaucer | last post by:
I am creating a class with operator overloads. It makes references to another class I've created, but do not wish to modify. I try to overload an operator having arguments having the other class type, but none of the new class type. However it does return a type of the new class. The compiler tells me that at least one parameter must be of the containing type. Is there a way to do this? The other class hos no reference to this new class. Is...
5
8011
by: Gang Zhang | last post by:
Hi, I have 2 overloaded functions as below: myfunc(byval val as Decimal) as string myfunc(byval val as String) as string When calling the function with a single like: dim num1 as single = ...
10
2223
by: shachar | last post by:
hi all. can i OverLoad Operators - such as Exclamation Mark "!" ? how?
1
1046
by: Nick Hall | last post by:
I'm getting what I think is a bug in the way the VB compiler determines the correct overloaded method to call. I have written a class to wrap System.Configuaration.ConfigurationSettings with some type-safe methods - for instance two methods are : - Public Overloads Shared Function GetInt32(ByVal key As String, ByVal defaultValue As Integer) As Integer .... End Function
1
1947
by: RShadow | last post by:
ok, this is going to drive me crazy. I did this a long time ago, but forgot how it I got it all to work. Now I just can't get anything to work. Can somebody please refer me to an example, book reference, or other resource that can explain how to build and use a shared library (.dll and .so) that is cross platform compatible. I understand that the loading of the library will be different from windows to linux, and the build process will...
0
2376
by: bcobra | last post by:
What am I doing wrong? the code: age Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %> <%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %> <MM:DataSet id="SSF2Pinky"
4
2712
by: Kevin Burton | last post by:
I have a base (MustInherit/abstact) class that looks like: Public MustInherit Class BaseClass End Class Then I have three derived classes: Public Class DerivedA Inherits BaseClass End Class
5
3483
by: richard.parker | last post by:
Hello, I need to overload operator new with affecting the system libraries. Has anyone done this? I've got 2 static libraries and application source code where the operator needs to be overloaded, but I need to link with the system libraries (frameworks) and I DO NOT want my overloads to be mapped to them. I'm working with some code that is currently working on Win32 but also needs to work on the Mac. Under windows this is very...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10351
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.