我的問題很簡單,但我不知道如何解決它:我有一個Visual Studio 2010項目與idl文件用於生成COM類型庫。該項目最初由VC++ 6.0創建。 VC 6.0可以在沒有任何錯誤的情況下編譯這個項目。但是,我最近轉換,並不斷嘗試編譯它在2010年,我獲得永諾以下控制檯輸出消息VC:如何強制MIDL編譯器在Visual Studio 2010中使用「C++模式」而不是「C模式」?
1>------ Build started: Project: myProject, Configuration: Debug Win32 ------
1>Build started 08.04.2013 11:23:12.
1>InitializeBuildStatus:
1> Touching ".\Debug\myProject.unsuccessfulbuild".
1>Midl:
1> Processing .\myFile.idl
1> myProject.idl
1>C:\Programme\Microsoft Visual Studio 10.0\VC\include\typeinfo(29): fatal error C1189: #error : This header requires a C++ compiler ...
1>
1>midl : command line error MIDL1003: error returned by the C preprocessor (2)
1>
1>Build FAILED.
我已經想通了,這並不僅僅意味着,該MIDL調用編譯器在「C模式」中,但不是在「C++模式」中。該項目既不包含.c也不包含.cpp,只包含.h和.idl文件:C/C++部分在項目屬性頁面不可用。我嘗試添加一個dummy.cpp文件,以使缺少的部分可用,並且能夠默認C++編譯器。
的MIDL文件看起來像:
import "unknwn.idl";
//Globale Definitionen
#include "MyProjectGlobaleDefinitionen.h"
//Interfacedeklarationen
interface IMyProjectDcomSchnittstellen;
[
uuid(E6C14CB3-CFFE-11d4-B1A2-00104BC1A971),
helpstring(MyProject_SCHNITTSTELLE_RELEASE_2_HELPSTRING),
version (MyProject_SCHNITTSTELLE_VERSIONSNUMMER)
]
library MyProject_SCHNITTSTELLE_KURZBEZEICHNER
{
importlib("..\\..\\..\\Files\\DLL\\stdole32.tlb");
importlib("..\\..\\..\\Files\\DLL\\MSADO15.dll");
// #include "..\..\common\Hresult_Werte.h"
#include "MyProjectDcomSchnittstellenTypdefinitionen.idl"
#include "IObj1ManagerMyProject.idl"
#include "IObj1ManagerMyProjectEvents.idl"
#include "IObj2Manager.idl"
#include "IObj2NotifySink.idl"
//************ Obj2Manager **************************
[uuid(F0284CF2-8E24-11d4-8941-006097AA387A)]
coclass Obj2Manager
{
[default] interface IObj2Manager;
[default, source] interface IObj2NotifySinkEvents;
}
//************ Obj1ManagerMyProject ************************
[uuid(E6C14CB2-CFFE-11d4-B1A2-00104BC1A971)]
coclass Obj1ManagerMyProject
{
[default] interface IObj1ManagerMyProject;
[default, source] interface IObj1ManagerMyProjectEvents;
}
}; //Ende library Obj1_myProject
我怎麼能強制MIDL援引在 「C++模式」 的編譯器/預處理器?
你錯過了一些東西,消息說'C預處理器',而不是'C編譯器'。你的中檔文件肯定有問題。你能在這裏展示嗎? – 2013-04-08 10:02:36
已更新帖子... Midl內容就在那裏。 – 2013-04-08 10:24:23
看不到任何...?! – 2013-04-08 10:25:16