Export (0) Print
Expand All
Expand Minimize

Compiler Error C2346

Error Message

'function' cannot be compiled as native: reason

The compiler was unable to compile a function MSIL.

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

To correct this error

  1. Remove the code in the function that cannot be compiled to MSIL.

  2. Do not compile the module with /clr or mark the function as unmanaged with the unmanaged pragma.

Example

The following sample generates C2346.

// C2346.cpp
// compile with: /clr /c
// C2346 error expected
// processor: x86
#include <dos.h>   // definitions for _disable, _enable
#pragma intrinsic(_disable)
#pragma intrinsic(_enable)

ref class C {
   Object ^ f0;
public:
   Object ^ f1() { 
      _disable();
      _enable();
      return f0;
   }

   void f2() {
      _disable();
      _enable();
   }

   static void f3() {
      _disable();
      _enable();
   }
};

Community Additions

ADD
Show:
© 2014 Microsoft