From e7bda421235019b5fcb15cf0b6764d223405d615 Mon Sep 17 00:00:00 2001 From: auronandace Date: Mon, 8 Jun 2026 11:26:17 +0100 Subject: [PATCH 1/2] verify wchar header includes --- src/header/wchar/cbindgen.toml | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/header/wchar/cbindgen.toml b/src/header/wchar/cbindgen.toml index e5b52de4d8..15c2a51d33 100644 --- a/src/header/wchar/cbindgen.toml +++ b/src/header/wchar/cbindgen.toml @@ -1,11 +1,26 @@ -sys_includes = [ - "stdio.h", - "time.h", - "features.h", -] +# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/wchar.h.html +# +# Spec quotations relating to includes: +# - "FILE As described in ." +# - "locale_t As described in ." +# - "size_t As described in ." +# - "va_list As described in ." +# - "wchar_t As described in ." +# - "The tag tm shall be declared as naming an incomplete structure type, the contents of which are described in the header." +# - "WCHAR_MAX As described in ." +# - "WCHAR_MIN As described in ." +# - "NULL As described in ." +# - "Inclusion of the header may make visible all symbols from the headers , , , , , , and ." +# +# We use after_includes here instead of sys_includes to better order the includes while interspersing defines between them. +# +# stdint.h is permitted by POSIX to be fully included through the following chain: +# wchar.h > stdlib.h > fcntl.h > unistd.h > stdint.h +# relibc includes stdint.h here directly instead of indirectly because of how other header includes are defined +# time.h brings in bits/locale.h for locale_t +# time.h brings in features.h for deprecated annotations after_includes = """ -// uint32_t, WCHAR_MIN, WCHAR_MAX -#include +#include // for uint32_t, WCHAR_MIN, WCHAR_MAX #ifndef _WINT_T #define _WINT_T @@ -18,7 +33,10 @@ after_includes = """ // NULL, size_t, must come after wchar_t and wint_t #define __need_size_t #define __need_NULL -#include +#include // for size_t, wchar_t and NULL +#include // for va_list +#include // for FILE +#include // for tm #define WEOF (0xffffffffu) """ From 163c2ee66341e5b627c7dee58fc4ef7bec535318 Mon Sep 17 00:00:00 2001 From: auronandace Date: Mon, 8 Jun 2026 11:32:38 +0100 Subject: [PATCH 2/2] remove stdarg as it is brought in by stdio --- src/header/wchar/cbindgen.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/header/wchar/cbindgen.toml b/src/header/wchar/cbindgen.toml index 15c2a51d33..9bde4dc7dd 100644 --- a/src/header/wchar/cbindgen.toml +++ b/src/header/wchar/cbindgen.toml @@ -17,6 +17,7 @@ # stdint.h is permitted by POSIX to be fully included through the following chain: # wchar.h > stdlib.h > fcntl.h > unistd.h > stdint.h # relibc includes stdint.h here directly instead of indirectly because of how other header includes are defined +# stdio.h brings in stdarg.h for va_list # time.h brings in bits/locale.h for locale_t # time.h brings in features.h for deprecated annotations after_includes = """ @@ -34,7 +35,6 @@ after_includes = """ #define __need_size_t #define __need_NULL #include // for size_t, wchar_t and NULL -#include // for va_list #include // for FILE #include // for tm