Global Operators New/Delete and Visibility Across Translation Units

D

dilabox

Hello,

I have overloaded the global new, delete, new[] and delete[] operators
inside a "static library". The library uses private memory allocation
routines that must not be accessible from other translation units.
Other translation units are therefore expected to define and use their
own new/delete operators.

When I link to this library the global new/delete operators conflict,
and although no linker warnings are generated, the result is that
translation units access each others memory allocation routines.

How can I limit the scope of these operator definitions? Apparently it
is not enought to declare them as 'inline' functions, which should only
make them available to translation units which explicitly include the
headers where they are defined.

To avoid this ambiguity I have considered overloading one set of
operators with redundent parameters, such as: void* operator new(
size_t, int )

Any thoughts apreciated.

Thanks in advance,
- dila
 
A

Alf P. Steinbach

* (e-mail address removed):
I have overloaded the global new, delete, new[] and delete[] operators

Don't.

And please don't cross-post to clc++ and Microsoft groups.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top