C2664 compilation error by using typedef enum in a idl file

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hello!

I am migrating a VS6 project to VS2005. The project compiles and runs by
using VC6. By using VS2005 the compilation fails.

I found a question about the same problem but without any answer. So I am
using the example from this question:

FOO.IDL contains:

interface IPoint : IUnknown

{

typedef [v1_enum, public] enum _units

{

millimeters = 0,

inches,

points

} _units_t;

[propget, helpstring("property dX")] HRESULT dX([in] _units_t dimUnits,

[out, retval] double* pVal);

[propget, helpstring("property dY")] HRESULT dY([in] _units_t dimUnits,

[out, retval] double* pVal);

}

STDAFX.CPP contains:

STDAFX.H contains:

FOOBUG.CPP contains:

void FooBar( foo::IPointPtr pPoint )

{

double dXInches = pPoint->dX[inches]; // Get X value using inch units

double dYInches = pPoint->dY[inches];

}

FOOBUG.CPP now fails to compile with the following error messages:

FOOBUG.CPP(5) : error C2664: 'foo::IPoint::GetdX' : cannot convert parameter

1 from '_units' to foo::_units_t'

In the same idl file I defined some interfaces as well. But I don't have any
problems with those.

At the beginning I thought it is a very common problem but it doesn't seem so.

Does anybody know what the problem is?

Warm regards

Torsten

.