C and C ++ bool are different, but if you stick to the same compiler (in your case gcc), it should be safe, as this is a reasonable general scenario.
In C ++, bool has always been a keyword. C was not until C99, where they entered the keyword _Bool (since people used typedef or #define bool as int or char in C89 code, so directly adding bool as a keyword would violate the existing code); there is a stdbool.h header, which in C should have typedef or #define from _Bool to bool . Take a look at yourself; The implementation of the GCC is as follows:
#ifndef _STDBOOL_H #define _STDBOOL_H #ifndef __cplusplus #define bool _Bool #define true 1 #define false 0 #else #define _Bool bool #define bool bool #define false false #define true true #endif #define __bool_true_false_are_defined 1 #endif
This makes us think that, at least in GCC, both types are compatible (both in size and in alignment, so that the structure structure remains the same).
It is also worth noting the Itanium ABI , which is used by GCC and most other compilers (except Visual Studio, as Matti M. noted in the comments below) on many platforms, indicates that _Bool and bool follow the same rules. This is a serious guarantee. The third hint we can get is given in the Objective-C reference manual, which states that for Objective-C and Objective-C ++, which relate to the conventions in C and C ++, respectively, bool and _Bool equivalent; therefore, I would say that although the standards do not guarantee this, you can assume that yes, they are equivalent.
Edit:
If the standard does not guarantee compatibility between _Bool and bool (in size, alignment, and padding), what does?
When we say that these things are “architecture dependent,” we actually mean that they are ABI dependent. Each compiler implements one or more ABIs, and two compilers (or versions of the same compiler) are considered compatible if they implement the same ABI. Since it is expected that C code will be called in C ++, as this is ubiquitous, all the C ++ ABIs I have ever heard of distribute the local C ABI.
Since the OP asked about Beaglebone, we should check out ARM ABI , in particular the GNU ARM EABI used by Debian. As Justin Time notes in the comments, ARM ABI does state that C ++ ABI extends C and that _Bool and bool compatible , both have a size of 1, alignment 1 representing an unsigned machine character. So the answer to the question is on Beaglebone, yes, _Bool and bool compatible .