Partilhar via


Erro do compilador C2749

'type' : só pode lançar ou pegar alça para uma classe gerenciada com /clr:safe

Observações

Ao usar /clr:safe, você só pode lançar ou pegar um tipo de referência.

Para obter mais informações, consulte /clr (Common Language Runtime Compilation).

Exemplo

O exemplo a seguir gera 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 ^){}
}