Compartir a través de


Error del compilador C2658

'miembro': nueva definición en struct/union anónimas

Dos estructuras o uniones anónimas contenían declaraciones de miembro con el mismo identificador, pero con tipos diferentes. En /Za, también se obtiene este error para los miembros con el mismo identificador y tipo.

El ejemplo siguiente genera el error C2658:

// C2658.cpp
// compile with: /c
struct X {
   union { // can be struct too
      int i;
   };
   union {
      int i;   // Under /Za, C2658
      // int i not needed here because it is defined in the first union
   };
};

struct Z {
   union {
      char *i;
   };

   union {
      void *i;   // C2658 redefinition of 'i'
      // try the following line instead
      // void *ii;
   };
};