开发者

Expected declaration specifiers or '...' before bool

开发者 https://www.devze.com 2023-04-11 05:00 出处:网络
I wrote in C function: void func(int count,bool infini){ //... } I try compil开发者_如何学编程e this code with Code Blocks, (GCC) spike:

I wrote in C function:

    void func(int count,bool infini){
//...
}

I try compil开发者_如何学编程e this code with Code Blocks, (GCC) spike:

"expected declaration specifiers or '...' before bool"

. Where is bug?


Chances are that you are compiling in C mode. C does not have bool. Use int instead or include stdbool.h to get a #define of bool (only C99) or create a typedef / #define yourself (if your compiler doesn't have or you don't want to use stdbool.h. But GCC provides this header).

Alternatively in C99 code you can use _Bool instead (which is a keyword in C99, much like bool is to C++), but take in mind that C99 is not widely supported.


The bool is in C++ but not in C.

0

精彩评论

暂无评论...
验证码 换一张
取 消