当前位置: 代码迷 >> 单片机 >> 关于IAR使用结构变量的有关问题(msp430)
  详细解决方案

关于IAR使用结构变量的有关问题(msp430)

热度:59   发布时间:2016-04-28 15:18:11.0
关于IAR使用结构变量的问题(msp430)
本帖最后由 skevil 于 2013-08-25 19:23:52 编辑

#define uchar unsigned char
 
struct FindGB16
{
  uchar Index[3];
  uchar data[32];
};

struct FindGB16  GB16[]=   //为结构变量初始化
{
  "我", 0x20,0x24,0x24,0x24,0xFE,0x23,0x22,0x20,
      0xFF,0x20,0x22,0xAC,0x20,0x30,0x20,0x00,
      0x00,0x08,0x48,0x84,0x7F,0x02,0x21,0x10,
      0x09,0x06,0x1A,0x61,0x80,0xE0,0x00,0x00,
  
  "有", 0x04,0x04,0x04,0x84,0xE4,0x3C,0x27,0x24,
      0x24,0x24,0x24,0xF4,0x24,0x06,0x04,0x00,
      0x04,0x02,0x01,0x00,0xFF,0x09,0x09,0x09,
      0x09,0x49,0x89,0x7F,0x00,0x00,0x00,0x00,

  "一", 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
      0x80,0x80,0x80,0x80,0x80,0xC0,0x80,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

  "个", 0x80,0x80,0x40,0x20,0x10,0x08,0x04,0xE3,
      0x04,0x08,0x10,0x20,0x40,0xC0,0x40,0x00,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};



请问我这样初始化有什么问题吗?
Error[Pe101]: "FindGB16" has already been declared in the current scope (at line 3) C:\Users\Administrator\Desktop\TFT2.4\chinese.h 3 

Error[Pe148]: variable "GB16" has already been initialized (at line 9) C:\Users\Administrator\Desktop\TFT2.4\chinese.h 9 
为啥报错呢?

------解决方案--------------------
语法错误,初始化不是这样的,给你一个参考


typedef struct
{
  uchar Index[3];
  uchar data[32];
}FindGB16;
 
const FindGB16 GB16[4]=
{
  {
    {"我"},//这里其实有问题,"我"这个字符串应该不止三个字节
     {0x20,0x24,0x24,0x24,0xFE,0x23,0x22,0x20,