在CCS3.3中编译
#include <std.h>
#ifndef Bool
typedef enum{FALSE,TRUE} Bool;
#endif
出现如下编译错误
"Test.c", line 7: error: expected an identifier
"Test.c", line 7: error: expected an identifier
"Test.c", line 7: error: "Bool" has already been declared in the current scope
最初认为CCS3.3没有定义Bool类型(很多编译器都没有定义Bool类型),所以自己定义了typedef enum{FALSE,TRUE} Bool;类型。从编译错误信息中可以看出重复定义了,在CCS的安装目录D:\CCStudio_v3.3\bios_5_31_02\packages\ti\bios\include找到std.h文件,可以查找D:\CCStudio_v3.3\C6000\csl\include目录下的tistdtypes.h文件,其中定义了Bool类型。
typedef unsigned short Bool; /* boolean */
此处的Bool采用typedef定义,所以在#ifndef Bool不起作用。
去掉std.h的应用或者去掉自定义typedef enum{FALSE,TRUE} Bool;即可解决问题。