Skip to content

Commit d7bbd17

Browse files
ijcapritzel
authored andcommitted
Use <stdbool.h> even on bare metal
This is part of the compiler not the libc and so is ok to use. This addresses this compile error with the current compiler in Debian: ``` arm-none-eabi-gcc -march=armv5te -g -Os -marm -fpic -Wall -fno-common -fno-builtin -ffreestanding -nostdinc -fno-strict-aliasing -mno-thumb-interwork -fno-stack-protector -fno-toplevel-reorder -Wstrict-prototypes -Wno-format-nonliteral -Wno-format-security jtag-loop.c bare-metal.c -nostdlib -o jtag-loop.elf -T bare-metal.lds -Wl,-N In file included from jtag-loop.c:21: bare-metal.h:59:13: error: 'bool' cannot be defined via 'typedef' 59 | typedef int bool; | ^~~~ bare-metal.h:59:13: note: 'bool' is a keyword with '-std=c23' onwards ``` To allow the use of `stdbool` drop use of `-nostdinc` when building bare metal components. We will rely on the link phase and `-ffreestanding` along with `-nostdlib` to prevent accidental use of stdlib features. Signed-off-by: Ian Campbell <ijc@debian.org>
1 parent 1e057a0 commit d7bbd17

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ phoenix_info: phoenix_info.c
186186
$(SUNXI_BOOT_IMAGE) $< $@
187187

188188
ARM_ELF_FLAGS = -Os -marm -fpic -Wall
189-
ARM_ELF_FLAGS += -fno-common -fno-builtin -ffreestanding -nostdinc -fno-strict-aliasing
189+
ARM_ELF_FLAGS += -fno-common -fno-builtin -ffreestanding -fno-strict-aliasing
190190
ARM_ELF_FLAGS += -mno-thumb-interwork -fno-stack-protector -fno-toplevel-reorder
191191
ARM_ELF_FLAGS += -Wstrict-prototypes -Wno-format-nonliteral -Wno-format-security
192192

bare-metal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@
5353
#ifndef _BARE_METAL_H_
5454
#define _BARE_METAL_H_
5555

56+
#include <stdbool.h>
57+
5658
typedef unsigned int u32;
5759
typedef unsigned short int u16;
5860
typedef unsigned char u8;
59-
typedef int bool;
6061

6162
#ifndef NULL
6263
#define NULL ((void*)0)

0 commit comments

Comments
 (0)