我得到“初始值设定元素不是常量”以下声明错误。初始值设定元素不是恒>目标C
struct EBD_HEADER
{
char x;
int Key;
char Number;
int ID;
int Version;
}EBD_HEAD;
struct EBD_TRAILER
{
int Crc_0;
int Crc_1;
int Etx;
}EBD_TRAIL;
static const int EBD_HEADER_SIZE = sizeof(EBD_HEAD);
static const int EBD_TRAILER_SIZE = sizeof(EBD_TRAIL);
static const int RMH_ENCODED_MSG_OVERHEAD = EBD_HEADER_SIZE +
EBD_TRAILER_SIZE; //**error:Intializer Element is not a constant**
静态const int的RMH_ENCODED_MSG_OVERHEAD =的sizeof(EBD_HEAD)+的sizeof(EBD_TRAIL);这个编译好。不知道为什么。 – taskinoor 2011-05-17 11:14:22
@taskinoor:是的,我照你说的,它works.But我有7〜8个这样的声明,所以我换成宏作为epatel问我要不要 – spandana 2011-05-17 11:35:26
@ron,是epatel者的回答更好。我甚至不是答案。我只是好奇这里发生了什么。 – taskinoor 2011-05-17 11:47:23