C 结构上的初始化失败

C 结构上的初始化失败,c,struct,C,Struct,我一直在尝试在主服务器之前运行此功能(尚未调用)。它说初始化失败。 原因可能是什么 编译器抱怨大括号的数量,但它们似乎没有问题 struct contain { char* a; int allowed; struct suit { struct t { char* option; int count; }; struct inner { char* op

我一直在尝试在主服务器之前运行此功能(尚未调用)。它说初始化失败。 原因可能是什么

编译器抱怨大括号的数量,但它们似乎没有问题

struct contain {
   char* a;         
   int allowed;

   struct suit {
      struct t {
         char* option;
         int count;      
      };

      struct inner {
         char* option; 
         int count;      
      };        
   };
};

// initialize
struct contain _vector = { 
    .a = "John",
    .allowed = 1,
    .suit = {
                 .t = {
                    .option = "ON",
                    .count = 7
                 },
                 .inner = {
                    .option = "ON",
                    .count = 7
                 }          
              }
};

您需要实际声明内部结构类型的成员

struct contain {
char* a;         
int allowed;

struct suit {
       struct t {
              char* option;
              int count;      
       } t;

       struct inner {
              char* option; 
              int count;      
       } inner;
} suit;
};

您需要实际声明内部结构类型的成员

struct contain {
char* a;         
int allowed;

struct suit {
       struct t {
              char* option;
              int count;      
       } t;

       struct inner {
              char* option; 
              int count;      
       } inner;
} suit;
};

您需要实际声明内部结构类型的成员

struct contain {
char* a;         
int allowed;

struct suit {
       struct t {
              char* option;
              int count;      
       } t;

       struct inner {
              char* option; 
              int count;      
       } inner;
} suit;
};

您需要实际声明内部结构类型的成员

struct contain {
char* a;         
int allowed;

struct suit {
       struct t {
              char* option;
              int count;      
       } t;

       struct inner {
              char* option; 
              int count;      
       } inner;
} suit;
};

您将
结构套件
声明为
结构包含
中的类型,但从未声明该类型的变量。
suit
t
internal
都不是变量。你可能想要像这样的东西

struct suit {
   struct t {
          char* option;
          int count;      
   } suit_t;

   struct inner {
          char* option; 
          int count;      
   } suit_inner;        
} suit_object;
};

尽管由于
t
internal
基本上是同一时间,那么您可能希望将其单独声明为一个类型,并将
t
internal
变量设置为该类型。

您将
struct suit
声明为
struct contain
中的一个类型,但您从未声明过这种类型的变量。
suit
t
internal
都不是变量。你可能想要像这样的东西

struct suit {
   struct t {
          char* option;
          int count;      
   } suit_t;

   struct inner {
          char* option; 
          int count;      
   } suit_inner;        
} suit_object;
};

尽管由于
t
internal
基本上是同一时间,那么您可能希望将其单独声明为一个类型,并将
t
internal
变量设置为该类型。

您将
struct suit
声明为
struct contain
中的一个类型,但您从未声明过这种类型的变量。
suit
t
internal
都不是变量。你可能想要像这样的东西

struct suit {
   struct t {
          char* option;
          int count;      
   } suit_t;

   struct inner {
          char* option; 
          int count;      
   } suit_inner;        
} suit_object;
};

尽管由于
t
internal
基本上是同一时间,那么您可能希望将其单独声明为一个类型,并将
t
internal
变量设置为该类型。

您将
struct suit
声明为
struct contain
中的一个类型,但您从未声明过这种类型的变量。
suit
t
internal
都不是变量。你可能想要像这样的东西

struct suit {
   struct t {
          char* option;
          int count;      
   } suit_t;

   struct inner {
          char* option; 
          int count;      
   } suit_inner;        
} suit_object;
};

虽然由于
t
internal
基本上是同一时间,那么您可能希望将其单独声明为一个类型,并将
t
internal
变量设置为该类型。

.membername=
称为成员初始化语法,使用它需要成员,不仅仅是decls。
.membername=
称为成员初始化语法,使用它需要成员,而不仅仅是decls。
.membername=
称为成员初始化语法,使用它需要成员,而不仅仅是decls。
.membername=
称为成员初始化语法,使用它需要成员,不仅仅是decls。