[U-Boot] [PATCH] include: define bool type in a more portable way
Masahiro Yamada
yamada.m at jp.panasonic.com
Tue Nov 19 04:10:23 CET 2013
Hello Wolfgang, Tom.
> > Currently U-boot defins bool type by including <stdbool.h>
> > rather than defining directly.
> > But it does not work for some cross compilers.
>
> Can you explain why this fails?
At first, I have to admit that I misunderstood the reason of the error.
It turned out that this is __not__ a compiler issue.
I tried another Blackfin cross compiler, which is available at:
https://www.kernel.org/pub/tools/crosstool/
But compiling faied at the same place.
$ make CROSS_COMPILE=bfin-uclinux- bct-brettl2
<<snipped>>
bfin-uclinux-gcc -g -Os -ffixed-P3 -fomit-frame-pointer -mno-fdpic -ffunction-sections
-fdata-sections -mcpu=bf536-0.3 -D__KERNEL__
-I/home/yamada/u-boot/include
-I/home/yamada/u-boot/arch/blackfin/include -fno-builtin -ffreestanding -nostdinc
-isystem /opt/gcc-4.6.3-nolibc/bfin-uclinux/bin/../lib/gcc/bfin-uclinux/4.6.3/include
-pipe -DCONFIG_BLACKFIN -Wall -Wstrict-prototypes -fno-stack-protector
-Wno-format-nonliteral -Wno-format-security -o cmd_test.o cmd_test.c -c
In file included from /home/yamada/u-boot/arch/blackfin/include/asm/blackfin.h:13:0,
from /home/yamada/u-boot/include/common.h:92,
from cmd_test.c:17:
/home/yamada/u-boot/arch/blackfin/include/asm/blackfin_local.h:54:1:
error: unknown type name 'bool'
make[2]: *** [cmd_test.o] Error 1
make[2]: Leaving directory `/home/yamada/u-boot/common'
make[1]: *** [common/built-in.o] Error 2
make[1]: Leaving directory `/home/yamada/u-boot'
make: *** [bct-brettl2] Error 2
The issue resides in common/cmd_test.c
I posted a patch to fix this build error in a different way.
http://patchwork.ozlabs.org/patch/292247/
Tom,
I think both can fix the error and you can select.
- This patch
- http://patchwork.ozlabs.org/patch/292247/
> > +enum {
> > + false = 0,
> > + true = 1
> > +};
> > +
>
> This looks fishy to me. Files that used to include <stdbool.h> do
> not necessarily include <linux/stddef.h>, so they may now be missing
> the definitions of "true" and "false".
Yes. I noticed this. But it is Linux's way.
So I intentionally put "bool" in <include/linux/types.h>
and "true" and "false" in <include/linux/stddef.h>.
> I can't say that I'm happy with that. I think we should first
> understand the real cause of the problem.
Now the real cause is clear.
FYI:
stdbool.h is usually something like follows.
Note it uses _STDBOOL_H as an include gurad.
/*
* ISO C Standard: 7.16 Boolean type and values <stdbool.h>
*/
#ifndef _STDBOOL_H
#define _STDBOOL_H
#ifndef __cplusplus
#define bool _Bool
#define true 1
#define false 0
#else /* __cplusplus */
/* Supporting <stdbool.h> in C++ is a GCC extension. */
#define _Bool bool
#define bool bool
#define false false
#define true true
#endif /* __cplusplus */
/* Signal that all the definitions are present. */
#define __bool_true_false_are_defined 1
#endif /* stdbool.h */
Best Regards
Masahiro Yamada
More information about the U-Boot
mailing list