Thread: "Non-function" error

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    28

    Question "Non-function" error

    The following code:
    Code:
    inline void * __cdecl operator new(unsigned int size,
        const char *file, int line)
    {
    	void *ptr = (void *)malloc(size);
    	AddTrack((DWORD)ptr, size, file, line);
    	return(ptr);
    };

    gives me
    Code:
    error: declaration of `operator new' as non-function
    Why?

  2. #2
    Registered User
    Join Date
    Mar 2005
    Posts
    28
    Okay, I managed to eliminate that problem by commenting out the following in a header file (yes, if you haven't noticed, I'm using the example code from this):
    Code:
    #define DEBUG_NEW new(__FILE__, __LINE__)
    #define new DEBUG_NEW
    BUT I want to be able to #include this file and have it override the new operator with that macro to make it spew out some diagnostics. How do I do that?

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    28
    Problem solved by sticking the function definitions above the macro.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM

Tags for this Thread