首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

sizeof计算函数外宣言结构体被告知结构体未声明

2012-09-27 
sizeof计算函数外声明结构体被告知结构体未声明具体代码如下:#include stdio.hstruct aa {int bb}int

sizeof计算函数外声明结构体被告知结构体未声明
具体代码如下:
#include <stdio.h>
struct aa {
  int bb;
};
int main(){
  int sz=sizeof(aa);
  printf("aa=%d\n",sz);
  return 0;
}

报错如下:
headertest.c:6: error: ‘aa’ undeclared (first use in this function)
headertest.c:6: error: (Each undeclared identifier is reported only once
headertest.c:6: error: for each function it appears in.)

恳求高人指教,多谢!

[解决办法]
需要如下这样声明,否则你每次都要这样struct aa去引用了。
typedef struct{
int bb;
}aa;

热点排行