Compartir a través de


Error del compilador C2749

'tipo': solamente puede producir o detectar el identificador a una clase administrada con /clr:safe

Cuando se usa /clr:safe, solo se puede producir o capturar un tipo de referencia.

Para obtener más información, consulte /clr (Compilación de Common Language Runtime).

Ejemplo

El ejemplo siguiente genera el error C2749:

// C2749.cpp
// compile with: /clr:safe
ref struct MyStruct {
public:
   int i;
};

int main() {
   MyStruct ^x = gcnew MyStruct;

   // Delete the following 4 lines to resolve.
   try {
      throw (1);   // C2749
   }
   catch(int){}

   // OK
   try {
      throw (x);
   }
   catch(MyStruct ^){}
}