Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Nurtsi

Overloading 'new' as in gcc

This topic is 6182 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible (and how) to overload operator new as static in gcc. Works fine with VC6 like this: static inline void* operator new(size_t) However, gcc (atleast v2.96) gives error operator new was declared extern (in file 'new' that comes with the compiler) then static. Is there a way around this? If I can't declare new and delete as static they mess up my memory allocation routines. - Nurtsi Edited by - Nurtsi on July 21, 2001 5:03:37 AM

Share this post


Link to post
Share on other sites
Advertisement
I am guessing that overloading new and delete on a static level is probably illegal. Because this could result in a mismatch such as using a normal delete on a specialised new or vice versa.

Is it impossible for you to overload it on a per-class basis?

Share this post


Link to post
Share on other sites
I need to overload the global new and delete to allocate memory for buffers and such. If I want to allocate memory, for example, for a bitmap, I can''t use any class specific operators.

Declaring overloaded operators as static I can use my own operators for my code and the standard new and delete for other code, like STL. I can''t seem to avoid breaking STL with my own operators. Hence the need for static.

- Nurtsi

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!