Export (0) Print
Expand All
Expand Minimize

Compiler Error C2743

Error Message

'type' : cannot catch a native type with __clrcall destructor or copy constructor

A module compiled with /clr (not /clr:pure) attempted to catch an exception of native type and where the type's destructor or copy constructor uses __clrcall calling convention.

When compiled with /clr (not /clr:pure), exception handling expects the member functions in a native type to be __cdecl and not __clrcall. Native types with member functions using __clrcall calling convention cannot be caught in a module compiled with /clr.

For more information, see /clr (Common Language Runtime Compilation).

Example

The following sample generates C2743.

// C2743.cpp
// compile with: /clr
public struct S {
   __clrcall ~S() {}
};

public struct T {
   ~T() {}
};

int main() {
   try {}
   catch(S) {}   // C2743
   // try the following line instead
   // catch(T) {}

   try {}
   catch(S*) {}   // OK
}

Community Additions

ADD
Show:
© 2015 Microsoft