编译器错误 C2032

“identifier”:函数不能是结构/联合“structorunion”的成员

结构或联合具有成员函数,这在 C++ 中是允许的,但在 C 中不允许。若要解决此错误,请编译为 C++ 程序,或删除该成员函数。

以下示例生成 C2032:

// C2032.c
struct z {
   int i;
   void func();   // C2032
};

可能的解决方法:

// C2032b.c
// compile with: /c
struct z {
   int i;
};