From: Masahiro Yamada Date: Tue, 19 Nov 2013 12:10:23 +0900 Subject: [U-Boot] [PATCH] include: define bool type in a more portable way In-Reply-To: <20131118162856.1403C38043B@gemini.denx.de> References: <1384770105-32364-1-git-send-email-yamada.m@jp.panasonic.com> <20131118162856.1403C38043B@gemini.denx.de> Message-ID: <20131119121022.30A3.AA925319@jp.panasonic.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Wolfgang, Tom. > > Currently U-boot defins bool type by including > > 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 <> 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 do > not necessarily include , 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 and "true" and "false" in . > 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 */ #ifndef _STDBOOL_H #define _STDBOOL_H #ifndef __cplusplus #define bool _Bool #define true 1 #define false 0 #else /* __cplusplus */ /* Supporting 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