error C2059: syntax error : 'constant'

typedef struct tagDEF{
int a;
int b;
}DEF,ABC,FRT;
我将它放在自定义的一个头文件里,加上逗号后面的就出现语法错误,为什么说是常量?帮忙解释一下,很久以来一直没弄明白哪错了,谢谢!

typedef 是定义 什么 为 什么 。
你现在定义的是:
这种结构 struct tagDEF{
int a;
int b;
}
是 DEF 型, 也叫 ABC 型,也叫,FRT 型。
程序例:
typedef struct tagDEF{
int a; int b;
}DEF,ABC,FRT;

int main()
{
DEF abc={5,6},frt={7,8}; // 声明 abc,frt 是 DEF 型, 并初始化。
ABC a; // 声明 a 是 ABC 型
FRT f; // 声明 f 是 FRT 型
f.a=4;f.b=2;
a.a=0;a.b=1;
printf("%d %d %d %d\n",a.a,a.b,f.a,f.b);
printf("%d %d %d %d\n",abc.a,abc.b,frt.a,frt.b);
return 0;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-10-16
解决方法是把
#define N 10
这句话放在所有包含头文件include语句的下面的位置
也可以建议不要用宏
const int N=10;
这样也可以
N是个宏会被替换成10代码变成
typedef struct _IMAGE_SYMBOL {
union {
BYTE ShortName[8];
struct {
DWORD Short; // if 0, use LongName
DWORD Long; // offset into string table
} Name;
PBYTE LongName[2];
} 10;本回答被网友采纳
第2个回答  2020-04-02
头文件的上方有个0.把那个去掉
/**
A=1,
B=50,
C=3,The
roots
of
the
1x^2+50x+3=0
are:
x1=-49.9399
x2=-0.0600719.
A=5,
B=4,
C=6,
There
are
non-real
roots.(b*b-4*a*c<0)
A=0,
B=0,
C=0,The
roots
of
the
0x^2+0x+0=0
are:
x1=-1.#IND
x2=-1.#IND.(It
couse
the
infinite
solutions
when
A,B
and
C
are
all
0.)
A=10,
B=2,
C=1,There
are
non-real
roots.(b*b-4*a*c<0)
A=2,
B=7,
C=3,The
roots
of
the
2x^2+7x+3=0
are:
x1=-3
x2=-0.5.
*/
0
//就是这个,有这个玩意编译绝对通不过
#
include<iostream>
#
include<cmath>
第3个回答  2019-03-08
不是,枚举里的内容只能是C的标识符,而标识符是不能以数字开头的,你可以改为: enum
month{m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12};
这样就不会错了。
相似回答