Microsoft KB Archive/315002

= You receive the &quot;C4199&quot; compiler error together with the &quot;ATL4058&quot; warning when you build attributed ATL code in Visual C++ .NET =

Article ID: 315002

Article Last Modified on 6/27/2006

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual C++ .NET 2003 Standard Edition

-



This article was previously published under Q315002



SYMPTOMS
C4199 is an undocumented compiler warning. However, you may receive this warning in conjunction with an ATL4058 warning when you build attributed Active Template Library (ATL) code. For example, you could get the following message when you build the project:

warning C4199: coclass

Atl Attribute Provider : warning ATL4058: &quot;ISomeInterface&quot; is not an interface defined in embedded IDL. It will not be replaced with the corresponding IDispatchImpl.

NOTE: Visual C++ .NET supports both the managed code model that is provided by the .NET Framework and the unmanaged native Windows code model. The information in this article applies only to unmanaged Visual C++ code.



CAUSE
This error occurs because you did not define ISomeInterface in embedded interface definitions in your code.



RESOLUTION
When an interface that derives from IDispatch is not in embedded Interface Definition Language (IDL) code (or is derived from an interface that is not in embedded IDL code), the attribute provider cannot replace the interface with the corresponding IDispatchImpl, which should be of the form. IDispatchImpl The ATL attribute provider cannot determine the type information from the header file that defines the interface.

The resolution that you select depends on what you want to accomplish:
 * If your interface is a dispinterface or a dual interface and you are implementing the IDispatch methods, you can ignore the error message.
 * If your interface is a dispinterface or dual interface and you expect the attribute provider to implement the IDispatch methods (either through the use of an IDispatchImpl or the compiler to generate the IDispatch methods), the warning is letting you know that the attribute provider cannot implement the IDispatch methods for you. To fix this, derive your class from IDIspatchImpl instead of the interface.



STATUS
This behavior is by design.



Steps to Reproduce the Behavior
 Create an ATL project. Use the default options.  Add a C++ header file called Test.h that includes the following code to the project: // Test.h : Declaration of the CTest [ coclass ] class CTest: public IHTMLFiltersCollection { public : virtual HRESULT STDMETHODCALLTYPE get_length(long *p) {      return E_NOTIMPL; }   virtual HRESULT STDMETHODCALLTYPE get__newEnum(IUnknown **p) {      return E_NOTIMPL; }   virtual HRESULT STDMETHODCALLTYPE item(VARIANT *pvarIndex, VARIANT *pvarResult) {      return E_NOTIMPL; } };                     Add a C++ file named Test.cpp to the project that includes the following code: // Test.cpp : Implementation of CTest
 * 1) include 

 On the Project menu, click Properties. Click the C/C++ tab. Under the General category, change the warning level to Level 4(/W4). Apply the changes.</li> Build your project.</li></ol>
 * 1) include &quot;stdafx.h&quot;
 * 2) include &quot;Test.h&quot;

<div class="references_section">