编译器警告(等级 1)C4339

更新:2007 年 11 月

错误消息

“type”: 在 CLR 元数据中检测到使用了未定义的类型 — 使用此类型可能导致运行时异常

在为公共语言运行库编译的代码中没有定义类型。定义该类型以避免可能的运行时异常。

默认情况下关闭此警告。有关更多信息,请参见默认情况下处于关闭状态的编译器警告

下面的示例生成 C4339:

// C4339.cpp
// compile with: /W4 /clr /c
// C4339 expected
#pragma warning(default : 4339)

// Delete the following line to resolve.
class A;

// Uncomment the following line to resolve.
// class A{};


class X {
public:
   X() {}

   virtual A *mf() {
      return 0;
   }
};

X * f() {
   return new X();
}