我用C函数写的:
void func(int count,bool infini){
//...
}
我尝试使用代码块编译此代码,(GCC) spike:
"expected declaration specifiers or '...' before bool"
. bug在哪里?
最佳答案
很可能您正在以 C 模式编译。 C 没有bool
。使用 int
代替或包含 stdbool.h
以获得 bool
的 #define
(仅限 C99)或创建一个typedef/#define
自己(如果你的编译器没有或者你不想使用 stdbool.h
。但是 GCC 提供了这个头文件)。
或者,在 C99 代码中,您可以使用 _Bool
(这是 C99 中的关键字,很像 bool
之于 C++),但请记住 C99 不是广泛支持。
关于c++ - bool 之前的预期声明说明符或 '...',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7666784/