Skip to content

Do not try to typedef bool for bare-metal.[ch]#242

Closed
ijc wants to merge 1 commit into
linux-sunxi:masterfrom
ijc:c23-fix
Closed

Do not try to typedef bool for bare-metal.[ch]#242
ijc wants to merge 1 commit into
linux-sunxi:masterfrom
ijc:c23-fix

Conversation

@ijc

@ijc ijc commented May 31, 2026

Copy link
Copy Markdown
Contributor

Doing so results in the following 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

I'd have preferred to use stdbool.h but that is not easily available with -nostdinc.


I don't think this is an issue with the Debian compiler, just the fact that it is new enough to have c23 support and/or this new warning.

The affected function (uart0_puthex) never appears to have been used from when it was introduced in 4f144b3, so I guess it could be removed, but I figured it might be useful for local debug hacking etc. Could also just remove the newline support I guess.

Doing so results in the following 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
```

I'd have preferred to use `stdbool.h` but that is not easily available with
`-nostdinc`.
@ijc

ijc commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

Could do #243 instead, I think I prefer this one though.

@paulkocialkowski

Copy link
Copy Markdown
Member

Please don't open two different pull requests with two different ways to solve the same issue, it is quite annoying. If you like one solution over another, just make one pull request for it and discuss other possible ways in the commit message. If maintainers disagree with it, just respin it differently.

@paulkocialkowski

Copy link
Copy Markdown
Member

That's an interesting issue. What u-boot is doing is the following:

NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)

Which seems like a good way to handle it without the ugly sed part from your other commit.
Could you update this pull request in this direction and close the other one?

Thanks!

@ijc ijc closed this May 31, 2026
@ijc ijc deleted the c23-fix branch May 31, 2026 12:54
@ijc

ijc commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

Sorry, I fat fingered my git push and closed this PR by accidentally deleting the branch instead of updating it.

Seems like even after pushing the branch again I can't reopen. Please see #244 instead.

@paulkocialkowski

Copy link
Copy Markdown
Member

That's fine, as long as there is only one :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants