Question

My problem is simple, but I don't know how to resolve it: I have a Visual Studio 2010 project with idl files for generating COM type library. This project was originally created by VC++ 6.0. The VC 6.0 could compile this project without any error. But I converted it recently and keep trying to compile it in VC 2010. I'm allways getting the following console output message:

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.

I've already figured out that this does only mean, that the MIDL invokes the compiler in "C mode", but not in "C++ mode". The project contains neither .c nor .cpp, has only .h and .idl files: C/C++ section is NOT available at project property pages. I tried to add a dummy.cpp file, to make that missing section available and to be able to default the C++ compiler in it.

The Midl file looks like:

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

How can I force the MIDL to invoke the compiler/preprocessor in "C++ mode"?

Was it helpful?

Solution

Shouldn't this

#include "MyProjectDcomSchnittstellenTypdefinitionen.idl"

#include "IObj1ManagerMyProject.idl"
#include "IObj1ManagerMyProjectEvents.idl"

#include "IObj2Manager.idl"
#include "IObj2NotifySink.idl"

actually be this

import "MyProjectDcomSchnittstellenTypdefinitionen.idl"

import "IObj1ManagerMyProject.idl"
import "IObj1ManagerMyProjectEvents.idl"

import "IObj2Manager.idl"
import "IObj2NotifySink.idl"

Okay... How about this one here:

This page applies only to developers who have specific reasons to replace the Microsoft C/C++ preprocessor as the preprocessor used by MIDL, or to developers who must specify customized preprocessor switches. The MIDL switches /cpp_cmd, /cpp_opt, and /no_cpp are used to override the default behavior of the compiler. There is typically no reason to replace the Microsoft C/C++ preprocessor, nor to specify customized preprocessor switches.

The MIDL compiler uses a C preprocessor during initial processing of the IDL file. The build environment used when compiling the IDL files is associated with a default C/C++ preprocessor. If a different preprocessor is to be used, the MIDL compiler switch /cpp_cmd enables an override of the default C/C++-preprocessor name:

midl /cpp_cmd preprocessor_name filename

OTHER TIPS

In the include file MyProjectGlobaleDefinitionen.h there was an include present. I had only to remove this include, because it was not needed at all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top