[U-Boot] [PATCH] cmd_test: fix a compile error on Blackfin
Masahiro Yamada
yamada.m at jp.panasonic.com
Tue Nov 19 04:01:57 CET 2013
Before this commit, common/cmd_test.c defined
_STDBOOL_H in order to avoid including <stdbool.h>.
But this work-around is not a good idea.
Blackfin header file
arch/blackfin/include/asm/blackfin_local.h
uses bool type here:
extern bool bfin_os_log_check(void);
This means Blackfin boards which define CONFIG_SYS_HUSH_PARSER
always failed in compiling.
This commit fixes this issue by undefining true and false macro.
Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
---
For example, when I try to compile bct-brettl2 board,
I got an error like follows at compiling common/cmd_test.c.
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
This is not a compiler problem.
It looks like this behavior is common for all blackfin compilers.
common/cmd_test.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/common/cmd_test.c b/common/cmd_test.c
index bacc368..1800cff 100644
--- a/common/cmd_test.c
+++ b/common/cmd_test.c
@@ -5,15 +5,6 @@
* SPDX-License-Identifier: GPL-2.0+
*/
-/*
- * Define _STDBOOL_H here to avoid macro expansion of true and false.
- * If the future code requires macro true or false, remove this define
- * and undef true and false before U_BOOT_CMD. This define and comment
- * shall be removed if change to U_BOOT_CMD is made to take string
- * instead of stringifying it.
- */
-#define _STDBOOL_H
-
#include <common.h>
#include <command.h>
@@ -143,6 +134,12 @@ U_BOOT_CMD(
"[args..]"
);
+/*
+ * Undef true and false here to avoid macro expansion by <stdbool.h>
+ */
+#undef true
+#undef false
+
static int do_false(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
return 1;
--
1.8.3.2
More information about the U-Boot
mailing list