Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 273651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:29:21+00:00 2026-05-12T00:29:21+00:00

I am attempting to get Memory leak detection working with the help of these

  • 0

I am attempting to get Memory leak detection working with the help of these two articles:
http://msdn.microsoft.com/en-us/library/e5ewb1h3%28VS.80%29.aspx
http://support.microsoft.com/kb/q140858/

So in my stdafx.h I now have:

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

#define new new(_NORMAL_BLOCK,__FILE__,__LINE__)

The only problem is, I have a class which overrides the new function:

class Dummy
{    
  //overloaded new operator
  void FAR* operator new(size_t cb);
}

Now when I compile this code, I get:
error C2059: syntax error : ‘constant’
error C2091: function returns function

Any idea how I can fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:29:22+00:00Added an answer on May 12, 2026 at 12:29 am

    You can use pragma directives to save and restore the new macro when undefing for overloads. See [MSDN](http://msdn.microsoft.com/en-us/library/hsttss76(VS.71).aspx) for the exact syntax.

    E.g.

    #pragma push_macro("new")
    #undef new
    void FAR* operator new(size_t cb);
    #pragma pop_macro("new") 
    

    You can put these in headers, e.g.

    begin_new_override.h:

    #ifdef new
    #define NEW_WAS_DEFINED
    #pragma push_macro("new")
    #undef new
    #endif
    

    end_new_override.h:

    #ifdef NEW_WAS_DEFINED
    #undef NEW_WAS_DEFINED
    #pragma pop_macro("new")
    #endif
    

    And then

    #include "begin_new_override.h"
    void FAR* operator new(size_t cb);
    #include "end_new_override.h"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been attempting to get the MySQL Embedded Library working in my C#
Attempting to get Spring internationalization working. I have used classpath:messages basename, created .properties files
Im attempting to analyze a memory leak that has been driving me crazy for
I've been attempting to get an extremely large canvas working for several days now.
I'm attempting to compare two string arrays. Whenever I get to the while loop
am having some trouble with attempting to remove a memory leak from my code.
Can someone please help me find the memory leak which is occurring here? I
Attempting to get a very simple example of libconfig++ working. However I'm encountering the
Im attempting to get a block of text from a file I have already
I'm attempting to get rid of an app's HTML files and store their contents

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.