我有一个 C 项目,其结构如下:
Project
- fileA.h
- fileA.c
+ subdirB
- fileD.h
fileD.h 中有一个 bool 的 typedef 枚举:
typedef enum bool {
false = 0, /**< false (0) */
true /**< true (1) */
} bool;
在 fileA.c 中有几个使用 bool 作为参数的函数,因此包含了 fileD.h:
#include "subdirB/fileD.h" // header with bool typedef
#include "fileA.h" // own header with foo declaration
...
int foo (bool bar) {
...
return 0;
}
...
这些函数是全局的,所以它们的声明被添加到头文件A.h中:
int foo (bool bar);
然而,最后一点给我一个错误,“标识符布尔未定义”......我不明白为什么会这样?