Microsoft KB Archive/194861

= FIX: "AtlReportError: no overloaded function takes X parameters" =

Article ID: 194861

Article Last Modified on 12/1/2003

-

APPLIES TO

 Microsoft ActiveX Template Library 3.0, when used with:  Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Professional Edition

 Microsoft Visual C++ 6.0 Standard Edition 

-

<div class="notice_section">

This article was previously published under Q194861

<div class="symptoms_section">

SYMPTOMS
Porting an ATL 2.x project to ATL 3.0 might give you the following compilation error:

error C2661: 'AtlReportError' : no overloaded function takes 2 parameters.

<div class="cause_section">

CAUSE
AtlReportError does not have any default parameters in ATL 3.0. AtlReportError in ATL 2.1 did have default parameters.

<div class="resolution_section">

RESOLUTION
Specify all the parameters required by AtlReportError or complete the following steps:

<ol>  Use the CComCoClass static member Error which accepts default arguments. For example, replace: return AtlReportError(        CLSID_PolyCtl, _T("Must have between 3&100 sides")); with: // If your class is derived from CComCoClass<CMyClass, // &CLSID_MyClass>: return Error(_T("Must must have between 3 & 100 sides"));

// If not derived from CComCoClass<>: return CComCoClass<CMyClass, &CLSID_MyClass>::Error(        _T("Must must have between 3 & 100 sides")); </li> Modify \vc98\atl\include\atlcom.h so that all the function prototypes for AtlReportError accept default arguments. Essentially use the same prototypes used in ATL 2.1. The following code lists the various prototypes of AtlReportError and their default argument equivalents in the same order as AtlCom.h:

  Replace: inline HRESULT WINAPI AtlReportError(const CLSID& clsid, UINT nID,        const IID& iid, HRESULT hRes, HINSTANCE hInst) with: inline HRESULT WINAPI AtlReportError(const CLSID& clsid, UINT nID,     const IID& iid = GUID_NULL, HRESULT hRes = 0,      HINSTANCE hInst = _Module.GetResourceInstance) </li>  Replace: inline HRESULT WINAPI AtlReportError(const CLSID& clsid, UINT nID,        DWORD dwHelpID, LPCOLESTR lpszHelpFile, const IID& iid, HRESULT            hRes,         HINSTANCE hInst) with: inline HRESULT WINAPI AtlReportError(const CLSID& clsid, UINT nID,        DWORD dwHelpID, LPCOLESTR lpszHelpFile, const IID& iid =            GUID_NULL,         HRESULT hRes = 0, HINSTANCE hInst = _Module.GetResourceInstance) </li>  Replace: inline HRESULT WINAPI AtlReportError(const CLSID& clsid,        LPCSTR lpszDesc, DWORD dwHelpID, LPCSTR lpszHelpFile, const IID&            iid,         HRESULT hRes) with: inline HRESULT WINAPI AtlReportError(const CLSID& clsid,        LPCSTR lpszDesc, DWORD dwHelpID, LPCSTR lpszHelpFile,         const IID& iid = GUID_NULL, HRESULT hRes = 0) </li>  Replace: inline HRESULT WINAPI AtlReportError(const CLSID& clsid,        LPCSTR lpszDesc, const IID& iid, HRESULT hRes) with: inline HRESULT WINAPI AtlReportError(const CLSID& clsid,        LPCSTR lpszDesc, const IID& iid = GUID_NULL, HRESULT hRes = 0) </li>  Replace: inline HRESULT WINAPI AtlReportError(const CLSID& clsid,        LPCOLESTR lpszDesc, const IID& iid, HRESULT hRes) with: inline HRESULT WINAPI AtlReportError(const CLSID& clsid,        LPCOLESTR lpszDesc, const IID& iid = GUID_NULL, HRESULT hRes = 0) </li>  Replace: inline HRESULT WINAPI AtlReportError(const CLSID& clsid,        LPCOLESTR lpszDesc, DWORD dwHelpID,LPCOLESTR lpszHelpFile,         const IID& iid, HRESULT hRes) with: inline HRESULT WINAPI AtlReportError(const CLSID& clsid,        LPCOLESTR lpszDesc, DWORD dwHelpID, LPCOLESTR lpszHelpFile,         const IID& iid = GUID_NULL, HRESULT hRes = 0) </li></ul> </li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

This problem was corrected in Microsoft Visual C++ .NET.

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Jaganathan Thangavelu, Microsoft Corporation.

Keywords: kberrmsg kbbug kbfix kbnoupdate KB194861

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.