程序如下:
#include "stdio.h"
union{ /*定义一个联合*/ int i; struct{ /*在联合中定义一个结构*/ char first; char second; }half; }number;
main() { number.i=0x4241; /*联合成员赋值*/ printf("%c%c\n", number.half.first, mumber.half.second); number.half.first='a'; /*联合中结构成员赋值*/ number.half.second='b'; printf("%x\n", number.i); getch(); } 错误信息:
ccppc -g -mcpu=860 -ansi -nostdinc -DRW_MULTI_THREAD -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -I. -IC:\Tornado\target\h -DCPU=PPC860 -c C:\Tornado\target\proj\Project2\s truct.cpp C:\Tornado\target\proj\Project2\struct.cpp: In function `int main()': C:\Tornado\target\proj\Project2\struct.cpp:18: `mumber' undeclared (first use this functio n) C:\Tornado\target\proj\Project2\struct.cpp:18: (Each undeclared identifier is reported onl y once C:\Tornado\target\proj\Project2\struct.cpp:18: for each function it appears in.) C:\Tornado\target\proj\Project2\struct.cpp:22: warning: implicit declaration of function ` int getch(...)' make: *** [struct.o] Error 0x1
在其他的标准c环境编译OK的,why?焦急等待ing~~~!!!!