hobenkr
hobenkr

Reputation: 1234

Compiler error using arm-none-eabi-gcc and bool variables

I am trying to compile a usb loopback example for STM32 using arm-none-eabi-gcc but am stuck on a compiler error for bool variables. The error is error: expected ';', identifier or '(' before '_Bool' and the offending lines are

typedef enum
{
  FALSE = 0, TRUE  = !FALSE
}
bool;

From what I've read, it seems bool is an alias for _Bool while gcc transitions to bool being an actual type. Unfortunately I have no idea how to fix this. With some googling I've read that similar problems are sometimes related to having TRUE and FALSE defined elsewhere but I'm using largely unchanged code from STM and don't know of anywhere else they might be defined. I've also read that it could be due to linking against libc but get the same error when compiling with -nostdlib. Is there anything I can do to narrow down this problem? Thanks.

Upvotes: 0

Views: 1532

Answers (1)

hobenkr
hobenkr

Reputation: 1234

Since this typedef was trying to define a bool type and my compiler was trying to use the _Bool type, what I ended up doing was commenting out the typedef all together and just using

#define TRUE 1
#define FALSE 0

I'm not positive this solved the problem since I still can't get the usb device to enumerate, but the program now compiles.

Upvotes: 1

Related Questions