获取 MIDL 2003 重新定义错误
Getting MIDL 2003 Redefinition errors
我有一个非常简单的程序,我正在尝试编译它,然后再进一步构建它。我正在尝试学习 COM,因此跟随 here,我在 VS 2017 中创建了 app.h
和 app.cpp
文件并使用 ATL 模板。当我尝试构建解决方案时,我遇到了很多 MIDL 200 重新定义错误。
UPDATE(基于@Roman R. 的回复)请注意,如果我在 Dev 命令行上使用 cl /LD app.cpp
,我能够生成 app.dll
正确。 MIDL 2003 重新定义错误仅在尝试通过 Visual Studio 构建解决方案时出现。我正在使用 VS 2017 社区版,所以不确定 Visual Studio 的其他版本是否有同样的问题。
我的包含路径只是继承自父默认值,即标准 $(VC_IncludePath)
和 $(WindowsSDK_IncludePath)
。我的WindowsSDK版本是10.0.17763.0,MSVC版本是14.16.27023
//app.h
#pragma once
#define STRICT
#ifndef _WINVER
#define _WINVER 0x0A00
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0A00
#endif
#define _USRDLL
#define _ATL_ATTRIBUTES
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#include <SDKDDKVer.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
using namespace ATL;
//app.cpp
#include "app.h"
[module(dll, name = "app", helpstring = "APP 1.0 Type Library")];
[emitidl];
当我尝试构建解决方案时,出现了很多 MIDL2003 错误;下面 Debug\app.log
的片段:
Microsoft (R) 32b/64b MIDL Compiler Version 8.01.0622
Copyright (c) Microsoft Corporation. All rights reserved.
Processing .\vc140.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\wtypes.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\wtypesbase.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\basetsd.h
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\guiddef.h
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\wincrypt.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\prsht.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\objidl.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\unknwn.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\propidlbase.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\oaidl.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\urlmon.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\oleidl.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\servprov.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\msxml.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\propidl.idl
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(56): error MIDL2003: redefinition : tagVersionedStream
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(60): error MIDL2003: redefinition : PROPSETFLAG_DEFAULT
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(61): error MIDL2003: redefinition : PROPSETFLAG_NONSIMPLE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(62): error MIDL2003: redefinition : PROPSETFLAG_ANSI
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(64): error MIDL2003: redefinition : PROPSETFLAG_UNBUFFERED
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(66): error MIDL2003: redefinition : PROPSETFLAG_CASE_SENSITIVE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(70): error MIDL2003: redefinition : PROPSET_BEHAVIOR_CASE_SENSITIVE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(90): error MIDL2003: redefinition : tagCAC
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(91): error MIDL2003: redefinition : tagCAUB
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(92): error MIDL2003: redefinition : tagCAI
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(93): error MIDL2003: redefinition : tagCAUI
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(94): error MIDL2003: redefinition : tagCAL
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(95): error MIDL2003: redefinition : tagCAUL
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(96): error MIDL2003: redefinition : tagCAFLT
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(97): error MIDL2003: redefinition : tagCADBL
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(98): error MIDL2003: redefinition : tagCACY
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(99): error MIDL2003: redefinition : tagCADATE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(100): error MIDL2003: redefinition : tagCABSTR
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(101): error MIDL2003: redefinition : tagCABSTRBLOB
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(102): error MIDL2003: redefinition : tagCABOOL
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(103): error MIDL2003: redefinition : tagCASCODE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(104): error MIDL2003: redefinition : tagCAPROPVARIANT
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(105): error MIDL2003: redefinition : tagCAH
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(106): error MIDL2003: redefinition : tagCAUH
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(107): error MIDL2003: redefinition : tagCALPSTR
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(108): error MIDL2003: redefinition : tagCALPWSTR
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(109): error MIDL2003: redefinition : tagCAFILETIME
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(110): error MIDL2003: redefinition : tagCACLIPDATA
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(111): error MIDL2003: redefinition : tagCACLSID
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(276): error MIDL2003: redefinition : tag_inner_PROPVARIANT
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(309): error MIDL2003: redefinition : PID_DICTIONARY
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(310): error MIDL2003: redefinition : PID_CODEPAGE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(311): error MIDL2003: redefinition : PID_FIRST_USABLE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(312): error MIDL2003: redefinition : PID_FIRST_NAME_DEFAULT
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(313): error MIDL2003: redefinition : PID_LOCALE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(314): error MIDL2003: redefinition : PID_MODIFY_TIME
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(315): error MIDL2003: redefinition : PID_SECURITY
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(316): error MIDL2003: redefinition : PID_BEHAVIOR
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(317): error MIDL2003: redefinition : PID_ILLEGAL
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(319): error MIDL2003: redefinition : PID_MIN_READONLY
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(320): error MIDL2003: redefinition : PID_MAX_READONLY
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(322): error MIDL2003: redefinition : PRSPEC_INVALID
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(323): error MIDL2003: redefinition : PRSPEC_LPWSTR
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(324): error MIDL2003: redefinition : PRSPEC_PROPID
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(339): error MIDL2003: redefinition : tagPROPSPEC
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(348): error MIDL2003: redefinition : tagSTATPROPSTG
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(368): error MIDL2003: redefinition : tagSTATPROPSETSTG
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(377): error MIDL2003: redefinition : IPropertyStorage
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(509): error MIDL2003: redefinition : IPropertySetStorage
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(546): error MIDL2003: redefinition : IEnumSTATPROPSTG
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(586): error MIDL2003: redefinition : IEnumSTATPROPSETSTG
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\ocidl.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\comcat.idl
Processing C:\Program Files (x86)\Microsoft Visual Studio17\Community\VC\Tools\MSVC.16.27023\atlmfc\include\atliface.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\oleacc.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\shtypes.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\MsHTML.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\dimm.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\dispex.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\dxgitype.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\dxgicommon.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\dxgiformat.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\MsHtmHst.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\docobj.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\ExDisp.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\ObjSafe.idl
.\vc140.idl(38): warning MIDL2214: semantic check incomplete due to previous errors
LINK : fatal error LNK1240: failed to compile IDL content
首先,总体而言,使用 ATL 属性并不是一个好主意。您指的是属于 Visual Studio 2008 的 MSDN 部分,并且 ATL 属性很快就被弃用了。
对 MyIncludes.h 的编辑对我适用于最新的 VS2017(其余部分按照演练步骤):
#pragma once
#include <sdkddkver.h> // <<--- This is the actual edit compared to MSDN article
#define _USRDLL
#define _ATL_ATTRIBUTES
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
using namespace ATL;
我有一个非常简单的程序,我正在尝试编译它,然后再进一步构建它。我正在尝试学习 COM,因此跟随 here,我在 VS 2017 中创建了 app.h
和 app.cpp
文件并使用 ATL 模板。当我尝试构建解决方案时,我遇到了很多 MIDL 200 重新定义错误。
UPDATE(基于@Roman R. 的回复)请注意,如果我在 Dev 命令行上使用 cl /LD app.cpp
,我能够生成 app.dll
正确。 MIDL 2003 重新定义错误仅在尝试通过 Visual Studio 构建解决方案时出现。我正在使用 VS 2017 社区版,所以不确定 Visual Studio 的其他版本是否有同样的问题。
我的包含路径只是继承自父默认值,即标准 $(VC_IncludePath)
和 $(WindowsSDK_IncludePath)
。我的WindowsSDK版本是10.0.17763.0,MSVC版本是14.16.27023
//app.h
#pragma once
#define STRICT
#ifndef _WINVER
#define _WINVER 0x0A00
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0A00
#endif
#define _USRDLL
#define _ATL_ATTRIBUTES
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#include <SDKDDKVer.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
using namespace ATL;
//app.cpp
#include "app.h"
[module(dll, name = "app", helpstring = "APP 1.0 Type Library")];
[emitidl];
当我尝试构建解决方案时,出现了很多 MIDL2003 错误;下面 Debug\app.log
的片段:
Microsoft (R) 32b/64b MIDL Compiler Version 8.01.0622
Copyright (c) Microsoft Corporation. All rights reserved.
Processing .\vc140.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\wtypes.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\wtypesbase.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\basetsd.h
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\guiddef.h
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\wincrypt.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\prsht.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\objidl.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\unknwn.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\propidlbase.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\oaidl.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\urlmon.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\oleidl.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\servprov.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\msxml.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\propidl.idl
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(56): error MIDL2003: redefinition : tagVersionedStream
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(60): error MIDL2003: redefinition : PROPSETFLAG_DEFAULT
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(61): error MIDL2003: redefinition : PROPSETFLAG_NONSIMPLE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(62): error MIDL2003: redefinition : PROPSETFLAG_ANSI
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(64): error MIDL2003: redefinition : PROPSETFLAG_UNBUFFERED
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(66): error MIDL2003: redefinition : PROPSETFLAG_CASE_SENSITIVE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(70): error MIDL2003: redefinition : PROPSET_BEHAVIOR_CASE_SENSITIVE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(90): error MIDL2003: redefinition : tagCAC
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(91): error MIDL2003: redefinition : tagCAUB
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(92): error MIDL2003: redefinition : tagCAI
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(93): error MIDL2003: redefinition : tagCAUI
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(94): error MIDL2003: redefinition : tagCAL
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(95): error MIDL2003: redefinition : tagCAUL
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(96): error MIDL2003: redefinition : tagCAFLT
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(97): error MIDL2003: redefinition : tagCADBL
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(98): error MIDL2003: redefinition : tagCACY
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(99): error MIDL2003: redefinition : tagCADATE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(100): error MIDL2003: redefinition : tagCABSTR
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(101): error MIDL2003: redefinition : tagCABSTRBLOB
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(102): error MIDL2003: redefinition : tagCABOOL
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(103): error MIDL2003: redefinition : tagCASCODE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(104): error MIDL2003: redefinition : tagCAPROPVARIANT
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(105): error MIDL2003: redefinition : tagCAH
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(106): error MIDL2003: redefinition : tagCAUH
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(107): error MIDL2003: redefinition : tagCALPSTR
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(108): error MIDL2003: redefinition : tagCALPWSTR
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(109): error MIDL2003: redefinition : tagCAFILETIME
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(110): error MIDL2003: redefinition : tagCACLIPDATA
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(111): error MIDL2003: redefinition : tagCACLSID
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(276): error MIDL2003: redefinition : tag_inner_PROPVARIANT
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(309): error MIDL2003: redefinition : PID_DICTIONARY
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(310): error MIDL2003: redefinition : PID_CODEPAGE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(311): error MIDL2003: redefinition : PID_FIRST_USABLE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(312): error MIDL2003: redefinition : PID_FIRST_NAME_DEFAULT
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(313): error MIDL2003: redefinition : PID_LOCALE
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(314): error MIDL2003: redefinition : PID_MODIFY_TIME
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(315): error MIDL2003: redefinition : PID_SECURITY
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(316): error MIDL2003: redefinition : PID_BEHAVIOR
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(317): error MIDL2003: redefinition : PID_ILLEGAL
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(319): error MIDL2003: redefinition : PID_MIN_READONLY
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(320): error MIDL2003: redefinition : PID_MAX_READONLY
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(322): error MIDL2003: redefinition : PRSPEC_INVALID
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(323): error MIDL2003: redefinition : PRSPEC_LPWSTR
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(324): error MIDL2003: redefinition : PRSPEC_PROPID
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(339): error MIDL2003: redefinition : tagPROPSPEC
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(348): error MIDL2003: redefinition : tagSTATPROPSTG
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(368): error MIDL2003: redefinition : tagSTATPROPSETSTG
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(377): error MIDL2003: redefinition : IPropertyStorage
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(509): error MIDL2003: redefinition : IPropertySetStorage
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(546): error MIDL2003: redefinition : IEnumSTATPROPSTG
c:\program files (x86)\windows kits\include.0.17763.0\um\propidlbase.idl(586): error MIDL2003: redefinition : IEnumSTATPROPSETSTG
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\ocidl.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\comcat.idl
Processing C:\Program Files (x86)\Microsoft Visual Studio17\Community\VC\Tools\MSVC.16.27023\atlmfc\include\atliface.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\oleacc.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\shtypes.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\MsHTML.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\dimm.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\dispex.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\dxgitype.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\dxgicommon.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\shared\dxgiformat.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\MsHtmHst.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\docobj.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\ExDisp.idl
Processing C:\Program Files (x86)\Windows Kits\Include.0.17763.0\um\ObjSafe.idl
.\vc140.idl(38): warning MIDL2214: semantic check incomplete due to previous errors
LINK : fatal error LNK1240: failed to compile IDL content
首先,总体而言,使用 ATL 属性并不是一个好主意。您指的是属于 Visual Studio 2008 的 MSDN 部分,并且 ATL 属性很快就被弃用了。
对 MyIncludes.h 的编辑对我适用于最新的 VS2017(其余部分按照演练步骤):
#pragma once
#include <sdkddkver.h> // <<--- This is the actual edit compared to MSDN article
#define _USRDLL
#define _ATL_ATTRIBUTES
#define _ATL_APARTMENT_THREADED
#define _ATL_NO_AUTOMATIC_NAMESPACE
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atltypes.h>
#include <atlctl.h>
#include <atlhost.h>
using namespace ATL;