【发布时间】:2012-03-27 02:16:48
【问题描述】:
不像很多其他的'x'在这里没有命名类型错误,我不认为这个涉及循环依赖,但我仍然无法弄清楚。
typedef struct /* structure definitions */
{
float mat[4][4];
} matrix_unit;
matrix_unit I = {
{ 1., 0., 0., 0.,
0., 1., 0., 0.,
0., 0., 1., 0.,
0., 0., 0., 1 },
};
matrix_unit *stack[50]; /* (line 456) array of pointers to act as a stack */
matrix_unit stackbase = I;
stack[0] = &stackbase; // 'stack' does not name a type
既然 stack 已经被声明为一个指向 matrix_unit 结构的指针栈,这不应该是有效的吗?
当我使用“gcc -c 3D.c”编译代码时,我从这些行中得到以下错误:
3D.c:457:1: error: initializer element is not constant
3D.c:458:1: warning: data definition has no type or storage class
3D.c:458:1: error: conflicting types for ‘stack’
3D.c:456:14: note: previous declaration of ‘stack’ was here
3D.c:458:1: error: invalid initializer
提前感谢您的帮助。
【问题讨论】:
-
使用 gcc 4.6.2 编译良好span>
-
嗯.. 我从 C++ 文件中包含在内。这应该有什么影响吗?我正在用 g++ 编译它
-
用 g++ 4.6.2 编译也很好。所以这不是这个子集的编译器问题。但是我只能测试您在帖子中写的内容。
-
我应该发布更多代码吗?此文件包含在 cpp 文件中,但我不确定其他任何内容会如何影响它。
-
我在 ubuntu 上运行 g++ 4.5.2。
标签: c