On 2026-03-27 09:04:25 +0100, noneofyourbusiness via Tinycc-devel wrote: > Daniil Gusev <[email protected]> wrote: > > The compiler itself builds and tests pass, so the warning does not appear > > to be critical. Could you please advise on the best way to handle this > > warning? > > 0. btw: you can disable inclusion of bcheck.c by an option in the configure > script > 1. fix it by not defining wchar_t et al in tcc - it's the job of the C > library (see also https://pubs.opengroup.org/onlinepubs/9799919799/) - imo > it's strange for tcc to do this job instead
The definition of wchar_t is done via a header, and how such a header is provided and processed depends on an agreement between the compiler and the C library when provided separately. But at the end, the choice will generally come from the compiler. For instance, under Linux, "gcc -E" on #include <stddef.h> wchar_t gives [...] # 344 "/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h" 3 4 typedef int wchar_t; [...] so this is defined by a header file provided by GCC. Ditto with Clang: [...] # 103 "/usr/lib/llvm-21/lib/clang/21/include/stddef.h" 3 # 1 "/usr/lib/llvm-21/lib/clang/21/include/__stddef_wchar_t.h" 1 3 # 24 "/usr/lib/llvm-21/lib/clang/21/include/__stddef_wchar_t.h" 3 typedef int wchar_t; [...] and both use typedef __WCHAR_TYPE__ wchar_t; where __WCHAR_TYPE__ is a macro that is either predefined by the compiler or defined by one of its internal header files. For instance: qaa:~> gcc -dM -E -xc /dev/null | grep __WCHAR_TYPE__ #define __WCHAR_TYPE__ int > > Currently, the following block exists in `tccdefs.h`: > > > > #if defined _WIN32 > > #define __WCHAR_TYPE__ unsigned short > > #define __WINT_TYPE__ unsigned short > > #elif defined __linux__ > > #define __WCHAR_TYPE__ int > > #define __WINT_TYPE__ unsigned int > > #else > > #define __WCHAR_TYPE__ int > > you could do the following instead (idk about win32, hence it stays) > > > #if defined _WIN32 > > #define __WCHAR_TYPE__ unsigned short > > #define __WINT_TYPE__ unsigned short > > after "git grep WCHAR", I'm even more convinced to just delete it - > let the C library do its job on POSIX-conformant platforms, let w32 > have its special sauce No, this won't work with the GNU libc, which does not provide a stddef.h header file. In any case, its header files are common to multiple architectures, so that it may not know how to define some types. So this should be kept at least for Linux. The #else case may not work everywhere. It may be better to have something like /usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h for this case: #ifndef __WCHAR_TYPE__ #define __WCHAR_TYPE__ int #endif i.e. define __WCHAR_TYPE__ only if it is not defined yet. This is not guaranteed to work everywhere, but this could improve the portability. > where do you get wchar_t from instead? stddef.h from libc first, if possible > - tcc's stddef.h is usually wronger than libc The GNU libc does not provide a stddef.h. FYI, on my Debian machine: qaa:~> dlocate include/stddef.h libclang-common-16-dev: /usr/lib/llvm-16/lib/clang/16/include/stddef.h libclang-common-15-dev: /usr/lib/llvm-15/lib/clang/15.0.7/include/stddef.h libclang-common-14-dev: /usr/lib/llvm-14/lib/clang/14.0.6/include/stddef.h libclang-common-13-dev: /usr/lib/llvm-13/lib/clang/13.0.1/include/stddef.h gcc-snapshot: /usr/lib/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16/accel/amdgcn-amdhsa/include/stddef.h gcc-snapshot: /usr/lib/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16/accel/nvptx-none/include/stddef.h gcc-snapshot: /usr/lib/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16/include/stddef.h tcc: /usr/lib/x86_64-linux-gnu/tcc/include/stddef.h libclang-common-21-dev:amd64: /usr/lib/llvm-21/lib/clang/21/include/stddef.h libgcc-16-dev:amd64: /usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h libclang-common-17-dev:amd64: /usr/lib/llvm-17/lib/clang/17/include/stddef.h libclang-common-19-dev:amd64: /usr/lib/llvm-19/lib/clang/19/include/stddef.h libgcc-12-dev:amd64: /usr/lib/gcc/x86_64-linux-gnu/12/include/stddef.h libclang-common-18-dev:amd64: /usr/lib/llvm-18/lib/clang/18/include/stddef.h libclang-common-20-dev:amd64: /usr/lib/llvm-20/lib/clang/20/include/stddef.h libgcc-15-dev:amd64: /usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h libgcc-13-dev:amd64: /usr/lib/gcc/x86_64-linux-gnu/13/include/stddef.h libgcc-14-dev:amd64: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h i.e. only compilers provide such a file. -- Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon) _______________________________________________ Tinycc-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/tinycc-devel
