原创 warning: missing braces around initializer

2008-7-10 16:22 5492 5 5 分类: 软件与OS

typedef struct
{
  char szTagName[20];   //位号名
  WORD wTagID;          //位号ID
 WORD wTagType;         //位号类型
  WORD wRWFlag;          //读写标记
  WORD wUpNodeType;      //挂接点
  char szPhyNode[20];        //物理子项
  char szModleName[20];  //所属模块名
  WORD wHisFlag;
  char szTagDesc[40];   //位号描述
  int wparam[8];
}cfg_SIGNAL;


#define SIGN_SYS_NUM 10


const cfg_SIGNAL g_SignSys[SIGN_SYS_NUM] = {
    {"DEBUG_MONITOR", -1, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","MONITOR", HISFLAG_NO,"DEBUG_MONITOR", 0,0,0,0,0,0,0,0},
    {"DEBUG_WNC", -2, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","WNC", HISFLAG_NO,"DEBUG_WNC", 0,0,0,0,0,0,0,0},
    {"DEBUG_PIC", -3, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","PIC", HISFLAG_NO,"DEBUG_PIC", 0,0,0,0,0,0,0,0},
    {"DEBUG_DATABASE",-4, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","DATABASE",HISFLAG_NO,"DEBUG_DATABASE",0,0,0,0,0,0,0,0},
    {"DEBUG_MODBUS", -5, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","MODBUS", HISFLAG_NO,"DEBUG_MODBUS", 0,0,0,0,0,0,0,0},
    {"DEBUG_IO", -6, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","IO", HISFLAG_NO,"DEBUG_IO", 0,0,0,0,0,0,0,0},
    {"DEBUG_BAK1", -7, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","BAK1", HISFLAG_NO,"DEBUG_BAK1", 0,0,0,0,0,0,0,0},
    {"DEBUG_BAK2", -8, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","BAK2", HISFLAG_NO,"DEBUG_BAK2", 0,0,0,0,0,0,0,0},
    {"DEBUG_BAK3", -9, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","BAK3", HISFLAG_NO,"DEBUG_BAK3", 0,0,0,0,0,0,0,0},
    {"DEBUG_BAK4", -10,TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","BAK4", HISFLAG_NO,"DEBUG_BAK4", 0,0,0,0,0,0,0,0}
};


 


//编译提示:


config.c:30: warning: missing braces around initializer
config.c:30: warning: (near initialization for `g_SignSys[0].wparam')


 



//修改为:


const cfg_SIGNAL g_SignSys[SIGN_SYS_NUM] = {
    {"DEBUG_MONITOR", -1, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","MONITOR", HISFLAG_NO,"DEBUG_MONITOR", {0,0,0,0,0,0,0,0}},
    {"DEBUG_WNC", -2, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","WNC", HISFLAG_NO,"DEBUG_WNC", {0,0,0,0,0,0,0,0}},
    {"DEBUG_PIC", -3, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","PIC", HISFLAG_NO,"DEBUG_PIC", {0,0,0,0,0,0,0,0}},
    {"DEBUG_DATABASE",-4, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","DATABASE",HISFLAG_NO,"DEBUG_DATABASE",{0,0,0,0,0,0,0,0}},
    {"DEBUG_MODBUS", -5, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","MODBUS", HISFLAG_NO,"DEBUG_MODBUS", {0,0,0,0,0,0,0,0}},
    {"DEBUG_IO", -6, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","IO", HISFLAG_NO,"DEBUG_IO", {0,0,0,0,0,0,0,0}},
    {"DEBUG_BAK1", -7, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","BAK1", HISFLAG_NO,"DEBUG_BAK1", {0,0,0,0,0,0,0,0}},
    {"DEBUG_BAK2", -8, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","BAK2", HISFLAG_NO,"DEBUG_BAK2", {0,0,0,0,0,0,0,0}},
    {"DEBUG_BAK3", -9, TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","BAK3", HISFLAG_NO,"DEBUG_BAK3", {0,0,0,0,0,0,0,0}},
    {"DEBUG_BAK4", -10,TAGTYPE_MC,RWFLAG_RW,UPNODETYPE_LOCAL,"","BAK4", HISFLAG_NO,"DEBUG_BAK4", {0,0,0,0,0,0,0,0}}
};



 


结论:对于初始化,需要严格按照定义,对于结构中的数组,必须加{}

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
5
关闭 站长推荐上一条 /3 下一条