Issue in porting ATL/COM dll to x64.

prxy 61 Reputation points
2020-12-23T09:00:50.727+00:00

Hi,

I'm trying to port ATL\COM dll to native X64. But compilation fails with below error for x64 platform. It works fine on x86.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\atlmfc\include\atlcom.h(3449): error C2259: 'ATL::CComContainedObject<contained>': cannot instantiate abstract class
1> with
1> [
1> contained=CXYZ
1> ] (compiling source file CXYZ.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\atlmfc\include\atlcom.h(3449): note: due to following members: (compiling source file CXYZ.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\atlmfc\include\atlcom.h(3449): note: 'HRESULT IXYZ::get_Window(long *)': is abstract (compiling source file CXYZ.cpp)
1>D:{path}\x64\Release\MIDL\CXYZ.h(122): note: see declaration of 'IXYZ::get_Window' (compiling source file CXYZ.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.14.26428\atlmfc\include\atlcom.h(1998): note: see reference to class template instantiation 'ATL::CComAggObject<T>' being compiled.

I know the function get_Window is defined in class CStockPropImpl but somehow compiler is not able find it definition for x64.
Below is some more information:
In .idl files, I've below entry for get_Window function

interface IXYZ : IDispatch
{
.
.
.
[propget, id(DISPID_HWND)]
 HRESULT Window([out, retval]long* phwnd);
.
.
.
}

MIDL is generating .h file correctly. Below is the entry for method get_Window

virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Window( 
            /* [retval][out] */ long *phwnd) = 0;

and below is implementation of IXYZ

class ATL_NO_VTABLE CXYZ : 
 public CComObjectRootEx<CComSingleThreadModel>,
 public CComCoClass<CXYZ, &CLSID_XYZ>,
 public CComControl<CXYZ>,
 public CStockPropImpl<CXYZ, IXYZ, &IID_IXYZ, &LIBID_XYZLib>
 .
 .
 .

I suspect the issue is beacuse of LONG_PTR size on x64 and x86 but not sure.

Any idea what could be the issue ?
Help appreciated.

Thanks in advance.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,705 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,545 questions
{count} votes

Accepted answer
  1. RLWA32 40,851 Reputation points
    2020-12-23T13:05:36.877+00:00

    IDL file generated by ATL wizards. All I did was add the Test method.

    // TestIDL.idl : IDL source for TestIDL  
    //  
      
    // This file will be processed by the MIDL tool to  
    // produce the type library (TestIDL.tlb) and marshalling code.  
      
    import "oaidl.idl";  
    import "ocidl.idl";  
      
    [  
    	object,  
    	uuid(58b7154c-9a1f-42ae-9df3-a137ffa37420),  
    	dual,  
    	nonextensible,  
    	pointer_default(unique)  
    ]  
    interface ITest : IDispatch  
    {  
    	[id(1)] HRESULT Test([in] LONG_PTR x, [out, retval] LONG_PTR *p);  
    };  
    [  
    	uuid(479c8a97-9e62-45c1-915d-9472dcfa2e06),  
    	version(1.0),  
    ]  
    library TestIDLLib  
    {  
    	importlib("stdole2.tlb");  
    	[  
    		uuid(e692375c-f763-4ea2-beb1-3667da07393f)  
    	]  
    	coclass Test  
    	{  
    		[default] interface ITest;  
    	};  
    };  
      
    import "shobjidl.idl";  
    

    Header from 32-bit MIDL compile -

    /* this ALWAYS GENERATED file contains the definitions for the interfaces */  
      
      
     /* File created by MIDL compiler version 8.01.0622 */  
    /* at Mon Jan 18 22:14:07 2038  
     */  
    /* Compiler settings for TestIDL.idl:  
        Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0622   
        protocol : dce , ms_ext, c_ext, robust  
        error checks: allocation ref bounds_check enum stub_data   
        VC __declspec() decoration level:   
             __declspec(uuid()), __declspec(selectany), __declspec(novtable)  
             DECLSPEC_UUID(), MIDL_INTERFACE()  
    */  
    /* @@MIDL_FILE_HEADING(  ) */  
      
      
      
    /* verify that the <rpcndr.h> version is high enough to compile this file*/  
    #ifndef __REQUIRED_RPCNDR_H_VERSION__  
    #define __REQUIRED_RPCNDR_H_VERSION__ 500  
    #endif  
      
    #include "rpc.h"  
    #include "rpcndr.h"  
      
    #ifndef __RPCNDR_H_VERSION__  
    #error this stub requires an updated version of <rpcndr.h>  
    #endif /* __RPCNDR_H_VERSION__ */  
      
    #ifndef COM_NO_WINDOWS_H  
    #include "windows.h"  
    #include "ole2.h"  
    #endif /*COM_NO_WINDOWS_H*/  
      
    #ifndef __TestIDL_i_h__  
    #define __TestIDL_i_h__  
      
    #if defined(_MSC_VER) && (_MSC_VER >= 1020)  
    #pragma once  
    #endif  
      
    /* Forward Declarations */   
      
    #ifndef __ITest_FWD_DEFINED__  
    #define __ITest_FWD_DEFINED__  
    typedef interface ITest ITest;  
      
    #endif 	/* __ITest_FWD_DEFINED__ */  
      
      
    #ifndef __Test_FWD_DEFINED__  
    #define __Test_FWD_DEFINED__  
      
    #ifdef __cplusplus  
    typedef class Test Test;  
    #else  
    typedef struct Test Test;  
    #endif /* __cplusplus */  
      
    #endif 	/* __Test_FWD_DEFINED__ */  
      
      
    /* header files for imported files */  
    #include "oaidl.h"  
    #include "ocidl.h"  
    #include "shobjidl.h"  
      
    #ifdef __cplusplus  
    extern "C"{  
    #endif   
      
      
    #ifndef __ITest_INTERFACE_DEFINED__  
    #define __ITest_INTERFACE_DEFINED__  
      
    /* interface ITest */  
    /* [unique][nonextensible][dual][uuid][object] */   
      
      
    EXTERN_C const IID IID_ITest;  
      
    #if defined(__cplusplus) && !defined(CINTERFACE)  
          
        MIDL_INTERFACE("58b7154c-9a1f-42ae-9df3-a137ffa37420")  
        ITest : public IDispatch  
        {  
        public:  
            virtual /* [id] */ HRESULT STDMETHODCALLTYPE Test(   
                /* [in] */ LONG_PTR x,  
                /* [retval][out] */ LONG_PTR *p) = 0;  
              
        };  
          
          
    #else 	/* C style interface */  
      
        typedef struct ITestVtbl  
        {  
            BEGIN_INTERFACE  
              
            HRESULT ( STDMETHODCALLTYPE *QueryInterface )(   
                ITest * This,  
                /* [in] */ REFIID riid,  
                /* [annotation][iid_is][out] */   
                _COM_Outptr_  void **ppvObject);  
              
            ULONG ( STDMETHODCALLTYPE *AddRef )(   
                ITest * This);  
              
            ULONG ( STDMETHODCALLTYPE *Release )(   
                ITest * This);  
              
            HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )(   
                ITest * This,  
                /* [out] */ UINT *pctinfo);  
              
            HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )(   
                ITest * This,  
                /* [in] */ UINT iTInfo,  
                /* [in] */ LCID lcid,  
                /* [out] */ ITypeInfo **ppTInfo);  
              
            HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )(   
                ITest * This,  
                /* [in] */ REFIID riid,  
                /* [size_is][in] */ LPOLESTR *rgszNames,  
                /* [range][in] */ UINT cNames,  
                /* [in] */ LCID lcid,  
                /* [size_is][out] */ DISPID *rgDispId);  
              
            /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )(   
                ITest * This,  
                /* [annotation][in] */   
                _In_  DISPID dispIdMember,  
                /* [annotation][in] */   
                _In_  REFIID riid,  
                /* [annotation][in] */   
                _In_  LCID lcid,  
                /* [annotation][in] */   
                _In_  WORD wFlags,  
                /* [annotation][out][in] */   
                _In_  DISPPARAMS *pDispParams,  
                /* [annotation][out] */   
                _Out_opt_  VARIANT *pVarResult,  
                /* [annotation][out] */   
                _Out_opt_  EXCEPINFO *pExcepInfo,  
                /* [annotation][out] */   
                _Out_opt_  UINT *puArgErr);  
              
            /* [id] */ HRESULT ( STDMETHODCALLTYPE *Test )(   
                ITest * This,  
                /* [in] */ LONG_PTR x,  
                /* [retval][out] */ LONG_PTR *p);  
              
            END_INTERFACE  
        } ITestVtbl;  
      
        interface ITest  
        {  
            CONST_VTBL struct ITestVtbl *lpVtbl;  
        };  
      
          
      
    #ifdef COBJMACROS  
      
      
    #define ITest_QueryInterface(This,riid,ppvObject)	\  
        ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )   
      
    #define ITest_AddRef(This)	\  
        ( (This)->lpVtbl -> AddRef(This) )   
      
    #define ITest_Release(This)	\  
        ( (This)->lpVtbl -> Release(This) )   
      
      
    #define ITest_GetTypeInfoCount(This,pctinfo)	\  
        ( (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) )   
      
    #define ITest_GetTypeInfo(This,iTInfo,lcid,ppTInfo)	\  
        ( (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) )   
      
    #define ITest_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)	\  
        ( (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) )   
      
    #define ITest_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)	\  
        ( (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) )   
      
      
    #define ITest_Test(This,x,p)	\  
        ( (This)->lpVtbl -> Test(This,x,p) )   
      
    #endif /* COBJMACROS */  
      
      
    #endif 	/* C style interface */  
      
      
      
      
    #endif 	/* __ITest_INTERFACE_DEFINED__ */  
      
      
      
    #ifndef __TestIDLLib_LIBRARY_DEFINED__  
    #define __TestIDLLib_LIBRARY_DEFINED__  
      
    /* library TestIDLLib */  
    /* [version][uuid] */   
      
      
    EXTERN_C const IID LIBID_TestIDLLib;  
      
    EXTERN_C const CLSID CLSID_Test;  
      
    #ifdef __cplusplus  
      
    class DECLSPEC_UUID("e692375c-f763-4ea2-beb1-3667da07393f")  
    Test;  
    #endif  
    #endif /* __TestIDLLib_LIBRARY_DEFINED__ */  
      
    /* Additional Prototypes for ALL interfaces */  
      
    /* end of Additional Prototypes */  
      
    #ifdef __cplusplus  
    }  
    #endif  
      
    #endif  
    

    Header form 64-bit MIDL compile -

    /* this ALWAYS GENERATED file contains the definitions for the interfaces */  
      
      
     /* File created by MIDL compiler version 8.01.0622 */  
    /* at Mon Jan 18 22:14:07 2038  
     */  
    /* Compiler settings for TestIDL.idl:  
        Oicf, W1, Zp8, env=Win64 (32b run), target_arch=AMD64 8.01.0622   
        protocol : all , ms_ext, c_ext, robust  
        error checks: allocation ref bounds_check enum stub_data   
        VC __declspec() decoration level:   
             __declspec(uuid()), __declspec(selectany), __declspec(novtable)  
             DECLSPEC_UUID(), MIDL_INTERFACE()  
    */  
    /* @@MIDL_FILE_HEADING(  ) */  
      
      
      
    /* verify that the <rpcndr.h> version is high enough to compile this file*/  
    #ifndef __REQUIRED_RPCNDR_H_VERSION__  
    #define __REQUIRED_RPCNDR_H_VERSION__ 500  
    #endif  
      
    #include "rpc.h"  
    #include "rpcndr.h"  
      
    #ifndef __RPCNDR_H_VERSION__  
    #error this stub requires an updated version of <rpcndr.h>  
    #endif /* __RPCNDR_H_VERSION__ */  
      
    #ifndef COM_NO_WINDOWS_H  
    #include "windows.h"  
    #include "ole2.h"  
    #endif /*COM_NO_WINDOWS_H*/  
      
    #ifndef __TestIDL_i_h__  
    #define __TestIDL_i_h__  
      
    #if defined(_MSC_VER) && (_MSC_VER >= 1020)  
    #pragma once  
    #endif  
      
    /* Forward Declarations */   
      
    #ifndef __ITest_FWD_DEFINED__  
    #define __ITest_FWD_DEFINED__  
    typedef interface ITest ITest;  
      
    #endif 	/* __ITest_FWD_DEFINED__ */  
      
      
    #ifndef __Test_FWD_DEFINED__  
    #define __Test_FWD_DEFINED__  
      
    #ifdef __cplusplus  
    typedef class Test Test;  
    #else  
    typedef struct Test Test;  
    #endif /* __cplusplus */  
      
    #endif 	/* __Test_FWD_DEFINED__ */  
      
      
    /* header files for imported files */  
    #include "oaidl.h"  
    #include "ocidl.h"  
    #include "shobjidl.h"  
      
    #ifdef __cplusplus  
    extern "C"{  
    #endif   
      
      
    #ifndef __ITest_INTERFACE_DEFINED__  
    #define __ITest_INTERFACE_DEFINED__  
      
    /* interface ITest */  
    /* [unique][nonextensible][dual][uuid][object] */   
      
      
    EXTERN_C const IID IID_ITest;  
      
    #if defined(__cplusplus) && !defined(CINTERFACE)  
          
        MIDL_INTERFACE("58b7154c-9a1f-42ae-9df3-a137ffa37420")  
        ITest : public IDispatch  
        {  
        public:  
            virtual /* [id] */ HRESULT STDMETHODCALLTYPE Test(   
                /* [in] */ LONG_PTR x,  
                /* [retval][out] */ LONG_PTR *p) = 0;  
              
        };  
          
          
    #else 	/* C style interface */  
      
        typedef struct ITestVtbl  
        {  
            BEGIN_INTERFACE  
              
            HRESULT ( STDMETHODCALLTYPE *QueryInterface )(   
                ITest * This,  
                /* [in] */ REFIID riid,  
                /* [annotation][iid_is][out] */   
                _COM_Outptr_  void **ppvObject);  
              
            ULONG ( STDMETHODCALLTYPE *AddRef )(   
                ITest * This);  
              
            ULONG ( STDMETHODCALLTYPE *Release )(   
                ITest * This);  
              
            HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )(   
                ITest * This,  
                /* [out] */ UINT *pctinfo);  
              
            HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )(   
                ITest * This,  
                /* [in] */ UINT iTInfo,  
                /* [in] */ LCID lcid,  
                /* [out] */ ITypeInfo **ppTInfo);  
              
            HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )(   
                ITest * This,  
                /* [in] */ REFIID riid,  
                /* [size_is][in] */ LPOLESTR *rgszNames,  
                /* [range][in] */ UINT cNames,  
                /* [in] */ LCID lcid,  
                /* [size_is][out] */ DISPID *rgDispId);  
              
            /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )(   
                ITest * This,  
                /* [annotation][in] */   
                _In_  DISPID dispIdMember,  
                /* [annotation][in] */   
                _In_  REFIID riid,  
                /* [annotation][in] */   
                _In_  LCID lcid,  
                /* [annotation][in] */   
                _In_  WORD wFlags,  
                /* [annotation][out][in] */   
                _In_  DISPPARAMS *pDispParams,  
                /* [annotation][out] */   
                _Out_opt_  VARIANT *pVarResult,  
                /* [annotation][out] */   
                _Out_opt_  EXCEPINFO *pExcepInfo,  
                /* [annotation][out] */   
                _Out_opt_  UINT *puArgErr);  
              
            /* [id] */ HRESULT ( STDMETHODCALLTYPE *Test )(   
                ITest * This,  
                /* [in] */ LONG_PTR x,  
                /* [retval][out] */ LONG_PTR *p);  
              
            END_INTERFACE  
        } ITestVtbl;  
      
        interface ITest  
        {  
            CONST_VTBL struct ITestVtbl *lpVtbl;  
        };  
      
          
      
    #ifdef COBJMACROS  
      
      
    #define ITest_QueryInterface(This,riid,ppvObject)	\  
        ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )   
      
    #define ITest_AddRef(This)	\  
        ( (This)->lpVtbl -> AddRef(This) )   
      
    #define ITest_Release(This)	\  
        ( (This)->lpVtbl -> Release(This) )   
      
      
    #define ITest_GetTypeInfoCount(This,pctinfo)	\  
        ( (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) )   
      
    #define ITest_GetTypeInfo(This,iTInfo,lcid,ppTInfo)	\  
        ( (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) )   
      
    #define ITest_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)	\  
        ( (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) )   
      
    #define ITest_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)	\  
        ( (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) )   
      
      
    #define ITest_Test(This,x,p)	\  
        ( (This)->lpVtbl -> Test(This,x,p) )   
      
    #endif /* COBJMACROS */  
      
      
    #endif 	/* C style interface */  
      
      
      
      
    #endif 	/* __ITest_INTERFACE_DEFINED__ */  
      
      
      
    #ifndef __TestIDLLib_LIBRARY_DEFINED__  
    #define __TestIDLLib_LIBRARY_DEFINED__  
      
    /* library TestIDLLib */  
    /* [version][uuid] */   
      
      
    EXTERN_C const IID LIBID_TestIDLLib;  
      
    EXTERN_C const CLSID CLSID_Test;  
      
    #ifdef __cplusplus  
      
    class DECLSPEC_UUID("e692375c-f763-4ea2-beb1-3667da07393f")  
    Test;  
    #endif  
    #endif /* __TestIDLLib_LIBRARY_DEFINED__ */  
      
    /* Additional Prototypes for ALL interfaces */  
      
    /* end of Additional Prototypes */  
      
    #ifdef __cplusplus  
    }  
    #endif  
      
    #endif  
      
      
      
    
    0 comments No comments

0 additional answers

Sort by: Most helpful