编译器错误 C3385

“class::function”:具有 DllImport 自定义特性的函数不能返回类实例

被定义为位于使用 DllImport 特性指定的 .dll 文件中的函数不能返回类的实例。

以下示例生成 C3385:

// C3385.cpp
// compile with: /clr /c
using namespace System;
using namespace System::Runtime::InteropServices;

struct SomeStruct1 {};

public ref struct Wrap {
   [ DllImport("somedll.dll", CharSet=CharSet::Unicode) ]
   static SomeStruct1 f1([In, Out] SomeStruct1 *pS);   // C3385
};