【发布时间】:2011-01-12 10:50:17
【问题描述】:
考虑 C 中的以下 typedef 结构:
21:typedef struct source{
22: double ds; //ray step
23: double rx,zx; //source coords
24: double rbox1, rbox2; //the box that limits the range of the rays
25: double freqx; //source frequency
26: int64_t nThetas; //number of launching angles
27: double theta1, thetaN; //first and last launching angle
28:}source_t;
我得到了错误:
globals.h:21:错误:重新定义“结构源”
globals.h:28:错误:“source_t”的类型冲突
globals.h:28: 注意:'source_t' 的先前声明在这里
我已经尝试使用其他格式来定义这个:
struct source{
...
};
typedef struct source source_t;
和
typedef struct{
...
}source_t;
两者都返回相同的错误。 为什么会这样?对我来说它看起来完全正确。
【问题讨论】:
-
看起来“globals.h”文件从源文件中包含了两次
-
非常适合我:ideone.com/kKj8q
-
基于 SirDarius 的评论:您是否在
globals.h中设置了 重新包含保护?