Compiler Error C3385
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C3385.
class::function' : a function that has a DllImport Custom attribute cannot return an instance of a class
A function defined as being in a .dll file specified with the DllImport attribute cannot return an instance of a class.
The following sample generates 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
};
The following sample generates C3385:
// C3385_2.cpp
// compile with: /clr:oldSyntax /c
using namespace System;
using namespace System::Runtime::InteropServices;
struct SomeStruct1 {};
public __gc struct Wrap {
[ DllImport("somedll.dll", CharSet=CharSet::Unicode) ]
static SomeStruct1 f1([In, Out] SomeStruct1 *pS); // C3385
};
Show: