simple c99 compiler
git clone git://
Log | Files | Refs | Submodules | README | LICENSE

commit eec601ebdb78b758cc248158386ef15a279e7f3a
parent 01ff22e4c7a52753acf510e0ce89862298b3a042
Author: Roberto E. Vargas Caballero <>
Date:   Fri, 20 Oct 2023 12:08:08 +0200

libc: Avoid inclusion order for FILE

Libc headers were designed to expose functions using FILE
only if stdio.h was included before. This can be consistent
with the writing of the standard that is not very clear about
this topic, but it can be a bit confusing for some users.

Minclude/stdio.h | 2+-
Minclude/wchar.h | 27+++++++++++++--------------
2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/include/stdio.h b/include/stdio.h @@ -55,7 +55,7 @@ enum _file_flags { * @flags: file open mode * @unbuf: tiny buffer for unbuffered i/o */ -typedef struct { +typedef struct _FILE { int fd; unsigned char *buf; unsigned char *rp; diff --git a/include/wchar.h b/include/wchar.h @@ -18,28 +18,27 @@ typedef int mbstate_t; struct tm; +struct _FILE; extern int vswscanf(const wchar_t *restrict, const wchar_t *restrict, __va_list); extern int vwprintf(const wchar_t *restrict, __va_list); extern int vwscanf(const wchar_t *restrict format, __va_list); -#ifdef _STDIO_H -extern int fwprintf(FILE *restrict, const wchar_t *restrict, ...); -extern int fwscanf(FILE *restrict, const wchar_t *restrict, ...); +extern int fwprintf(struct _FILE *restrict, const wchar_t *restrict, ...); +extern int fwscanf(struct _FILE *restrict, const wchar_t *restrict, ...); -extern int vfwprintf(FILE *restrict, const wchar_t *restrict, __va_list); -extern int vfwscanf(FILE *restrict, const wchar_t *restrict, __va_list); +extern int vfwprintf(struct _FILE *restrict, const wchar_t *restrict, __va_list); +extern int vfwscanf(struct _FILE *restrict, const wchar_t *restrict, __va_list); extern int vswprintf(wchar_t *restrict, size_t, const wchar_t *restrict, __va_list); -extern wint_t fgetwc(FILE *); -extern wint_t fputwc(wchar_t c, FILE *); -extern wint_t getwc(FILE *); -extern wint_t putwc(wchar_t, FILE *); -extern int fwide(FILE *, int); -extern wint_t ungetwc(wint_t, FILE *); -extern wchar_t *fgetws(wchar_t *restrict, int, FILE *restrict); -extern int fputws(const wchar_t *restrict, FILE *restrict); -#endif +extern wint_t fgetwc(struct _FILE *); +extern wint_t fputwc(wchar_t c, struct _FILE *); +extern wint_t getwc(struct _FILE *); +extern wint_t putwc(wchar_t, struct _FILE *); +extern int fwide(struct _FILE *, int); +extern wint_t ungetwc(wint_t, struct _FILE *); +extern wchar_t *fgetws(wchar_t *restrict, int, struct _FILE *restrict); +extern int fputws(const wchar_t *restrict, struct _FILE *restrict); extern int swprintf(wchar_t *restrict, size_t, const wchar_t *restrict, ...); extern int swscanf(const wchar_t *restrict, const wchar_t *restrict, ...);