我在 VS2005 中有一个项目 - C++ ATL 属性 COM - 我尝试迁移到 VS2013 我得到
error MIDL2025: syntax error : expecting a type specification near "MyStruct"
- 我发现让项目编译的唯一选择是在接口内添加一个 typdef 结构。这会导致项目编译,但任何依赖项目由于结构的重新定义而失败。
- 在依赖项目 C# 中,我得到以下内容
'MyStruct' is a 'type'
,这在给定上下文中无效“
有地方可以上传完整的解决方案吗?(所以任何人都可以尝试)
请指教
第一个项目COM C++的IDL
import "oaidl.idl";
import "ocidl.idl";
[uuid("71C7F1BB-699B-4594-A2C0-88454F54C36A")]
struct MyStruct
{
int X;
int Y;
};
[
uuid(CDEAA294-A77B-4703-A45A-C0001F126251),
version(1.0),
helpstring(" Cfc2_DataDictionary 1.0 Type Library")
]
library Cfc2_DataDictionary
{
struct MyStruct;
importlib("stdole2.tlb");
};
带有错误 ATL Attributed COM C++ 的接口
[对象,uuid(“15C5841B-4811-49F9-8961-C02240A6E0CF”),双重,帮助字符串(“IITransformMatrix接口”),pointer_default(唯一)]
__interface IITransformMatrix : IDispatch
{
//remark next line to get error MIDL 2025
typedef struct MyStruct MyStruct;
[helpstring("method Init")]
HRESULT PutInverseMatrix([in] const MyStruct * matrix);
HRESULT GetMatrix([out, retval] MyStruct* matrix);
};
依赖于上述两个项目的 C# 项目
using System.Runtime.InteropServices;
using Cfc2_DataDictionary;
using RnA_Utils;
namespace Job.NET
{
public class WaferGeometry
{
public WaferGeometry(IITransformMatrix stmatrix)
{
myWaferGeometry = stmatrix;
stmatrix.PutInverseMatrix(MyStruct);
}
private readonly IITransformMatrix myWaferGeometry;
}
}