Error c2660: gdiplus: gdiplusbase: Operator new: the function does not contain three parameters.

Source: Internet
Author: User
Tags microsoft address

When you debug a version of a Microsoft basic class (MFC) application using GDI +, an error message similar to the following may appear:
Error c2660: gdiplus: gdiplusbase: Operator new: the function does not contain three parameters.

 

Cause: In the debugging version, the MFC definition extends to the Preprocessor macro that loads the new operator of the new operator with two additional parameters.

MFC can use this information to extend the definition of program... In the debugging version to an overload with two additional parameters. The additional parameters are the source file name and the code line number. MFC can use this information to report Memory leakage to programmers in debugging mode. This applies to the MFC class because the new provided by the MFC accepts different overloading of additional parameters.

However, this extension is completed by the pre-processor because it affects all use of the new operator. If any non-MFC class is used in the project, the new operator can be expanded in the new class even if there is no suitable overload. This occurs in GDI +, So that you receive an error message during compilation.

 

To solve this problem, select one of the following methods:
1. Disable the pre-processor extension by commenting out the following line of code in the source file:
# Ifdef _ debug
# Define new debug_new
# Endif

Note: This method has the disadvantages of not using the function information in MFC, which can help you track memory allocation and leakage.

2. GDI + uses overload to provide new and delete operators by writing some code, which is acceptable and other parameters are discarded. You can paste the following code to a new header file and include the new header file instead of the gdiplus. h file.

/// Ensure that gdiplus header files work properly with MFC debug_new and STL header files.

# Define iterator _ iterator

# Ifdef _ debug

Namespace gdiplus
{
Namespace dllexports
{
# Include <gdiplusmem. h>
};

# Ifndef _ gdiplusbase_h
# DEFINE _ gdiplusbase_h
Class gdiplusbase
{
Public:
Void (operator delete) (void * in_pvoid)
{
Dllexports: gdipfree (in_pvoid );
}

Void * (operator new) (size_t in_size)
{
Return dllexports: gdipalloc (in_size );
}

Void (operator Delete []) (void * in_pvoid)
{
Dllexports: gdipfree (in_pvoid );
}

Void * (operator new []) (size_t in_size)
{
Return dllexports: gdipalloc (in_size );
}

Void * (operator new) (size_t nsize, lpcstr lpszfilename, int nline)
{
Return dllexports: gdipalloc (nsize );
}

Void operator Delete (void * P, lpcstr lpszfilename, int nline)
{
Dllexports: gdipfree (P );
}

};
# Endif // # ifndef _ gdiplusbase_h
}
# Endif // # ifdef _ debug

# Include <gdiplus. h>
# UNDEF iterator
/// Ensure that gdiplus. Lib is linked.
# Pragma comment (Lib, "gdiplus. lib ")

 

The original official Microsoft address is as follows:

Http://support.microsoft.com/kb/317799/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.