【原创】arm-linux-gcc “missing braces around initializer”编译错误处理

来源:互联网 发布:3g4g软件开发 编辑:程序博客网 时间:2024/06/05 21:02

【原创】arm-linux-gcc “missing braces around initializer”编译错误处理

Author: chad
Mail: linczone@163.com

本文可以自由转载,但转载请务必注明出处以及本声明信息。

程序编译出现如下错误:

db_app.c:24: warning: missing braces around initializer
db_app.c:24: warning: (near initialization for ‘MeterEventData[0]’)

数组原型如下:

//-----------------20140217-------------------------------------const char* MeterEventData[][2] ={    "","",    "id","integer primary key",    "point","integer NOT NULL DEFAULT 0",//测量点号    "addr","text NOT NULL DEFAULT '000000000000'",//表地址    "type","integer NOT NULL DEFAULT 0",//表类型,三相或单相表    "TimeScale","date",//数据时标-日期标识    "CmdBitMap","text NOT NULL DEFAULT '000000'",//数据有限性标识    "PowerLostTimes","integer",//失压总次数    "PowerLostRecord","blob",//失压总记录    "AllPowerLostTimes","integer",//全失压总次数    "AllPowerLostRecord","blob",//全失压记录    "OffPhaseTimes","integer",//断相总次数    "OffPhaseRecord","blob",//断相记录    "SwitchErrorTimes","integer",//负荷开关误动作总次数    "SwitchErrorRecord","blob",//负荷开关误动作记录    "MeterRunWorld","blob",//运行状态字    "VUnbalancedTimes","integer",//电压不平衡总次数    "VUnbalancedRecord","blob",//电压不平衡记录    "OpenLidTimes","integer",//开表盖总次数    "OpenLidRecord","blob",//开表盖记录    "ButtonUpTimes","integer",//开端钮盖总次数    "ButtonUpRecord","blob",//开端钮盖记录    "MagneticFieldAbnormalTimes","integer",//电能表磁场异常总次数    "MagneticFieldAbnormalRecord","blob",//磁场异常记录    "TimingTimes","integer",//电能表校时总次数    "TimingRecord","blob",//电能表校时记录    "ClearMeterTimes","integer",//电能表清零总次数    "ClearMeterRecord","blob",//电能表清零记录    "ClearDemandTimes","integer",//需量清零总次数    "ClearDemandRecord","blob",//需量清零记录    "ClearEventTimes","integer",//事件清零总次数    "ClearEventRecord","blob"//事件清零记录 };

但是在ubuntu虚拟机上使用gcc测试如下程序没有任何问题:
这里写图片描述
后来,经数组修改为如下形式后问题解决:

//-----------------20140217-------------------------------------const char* MeterEventData[][2] ={    {"",""},    {"id","integer primary key"},    {"point","integer NOT NULL DEFAULT 0"},//测量点号    {"addr","text NOT NULL DEFAULT '000000000000'"},//表地址    {"type","integer NOT NULL DEFAULT 0"},//表类型,三相或单相表    {"TimeScale","date"},//数据时标-日期标识    {"CmdBitMap","text NOT NULL DEFAULT '000000'"},//数据有限性标识    {"PowerLostTimes","integer"},//失压总次数    {"PowerLostRecord","blob"},//失压总记录    {"AllPowerLostTimes","integer"},//全失压总次数    {"AllPowerLostRecord","blob"},//全失压记录    {"OffPhaseTimes","integer"},//断相总次数    {"OffPhaseRecord","blob"},//断相记录    {"SwitchErrorTimes","integer"},//负荷开关误动作总次数    {"SwitchErrorRecord","blob"},//负荷开关误动作记录    {"MeterRunWorld","blob"},//运行状态字    {"VUnbalancedTimes","integer"},//电压不平衡总次数    {"VUnbalancedRecord","blob"},//电压不平衡记录    {"OpenLidTimes","integer"},//开表盖总次数    {"OpenLidRecord","blob"},//开表盖记录    {"ButtonUpTimes","integer"},//开端钮盖总次数    {"ButtonUpRecord","blob"},//开端钮盖记录    {"MagneticFieldAbnormalTimes","integer"},//电能表磁场异常总次数    {"MagneticFieldAbnormalRecord","blob"},//磁场异常记录    {"TimingTimes","integer"},//电能表校时总次数    {"TimingRecord","blob"},//电能表校时记录    {"ClearMeterTimes","integer"},//电能表清零总次数    {"ClearMeterRecord","blob"},//电能表清零记录    {"ClearDemandTimes","integer"},//需量清零总次数    {"ClearDemandRecord","blob"},//需量清零记录    {"ClearEventTimes","integer"},//事件清零总次数    {"ClearEventRecord","blob"}//事件清零记录 };
0 0