Andrei Dobrin
Andrei Dobrin

Reputation: 1185

Error 35 error C2661: 'operator new' : no overloaded function takes 2 arguments

I am not a proficient C++ programmer and I got a really big project(actually 24 of them) in one Visual Studio Solution.

I get this error from almost all of the project and I can't figure out how to solve it.

When I double click the error it gets me to this place:

for( int i = 0; i < nNewSize; i++ )
#pragma push_macro("new")
#undef new
        ::new((void*)(m_pData+i))TYPE;
#pragma pop_macro("new")

The Build Order Output gives me this:

c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\afxtempl.h(403): error C2661: 'operator new' : no overloaded function takes 2 arguments
19>          c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\afxtempl.h(368) : while compiling class template member function 'void CArray<TYPE,ARG_TYPE>::SetSize(INT_PTR,INT_PTR)'
19>          with
19>          [
19>              TYPE=D2D1_GRADIENT_STOP,
19>              ARG_TYPE=D2D1_GRADIENT_STOP
19>          ]
19>          c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\afxtempl.h(643) : see reference to function template instantiation 'void CArray<TYPE,ARG_TYPE>::SetSize(INT_PTR,INT_PTR)' being compiled
19>          with
19>          [
19>              TYPE=D2D1_GRADIENT_STOP,
19>              ARG_TYPE=D2D1_GRADIENT_STOP
19>          ]
19>          c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\afxtempl.h(355) : while compiling class template member function 'CArray<TYPE,ARG_TYPE>::~CArray(void)'
19>          with
19>          [
19>              TYPE=D2D1_GRADIENT_STOP,
19>              ARG_TYPE=D2D1_GRADIENT_STOP
19>          ]
19>          c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\afxrendertarget.h(1028) : see reference to class template instantiation 'CArray<TYPE,ARG_TYPE>' being compiled
19>          with
19>          [
19>              TYPE=D2D1_GRADIENT_STOP,
19>              ARG_TYPE=D2D1_GRADIENT_STOP
19>          ]

the afxrendertarget.h has this line at 1028

CArray<D2D1_GRADIENT_STOP, D2D1_GRADIENT_STOP>      m_arGradientStops;

I have tried to comment in my scripts the lines:

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

but it had no effect.

Please help me!

Upvotes: 0

Views: 2828

Answers (1)

James Kanze
James Kanze

Reputation: 153929

The small bit of code you show is horrible: if new is defined as a macro, you have undefined behavior, at least if you include any standard headers.

Still, the line I suppose the compiler is complaining about is something called placement new. To use it, you have to include the header <new>. (Which will not work if new has been defined as a macro. Find where this definition occurs, and get rid of it.)

Upvotes: 3

Related Questions