diff --git a/include/stddef.h b/include/stddef.h index b9c936d26e..6f0449055b 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -1,6 +1,19 @@ #ifndef _STDDEF_H #define _STDDEF_H #include + +// wchar_t should come before NULL and size_t +// according to comment in wchar cbindgen +#ifndef _WCHAR_T +#define _WCHAR_T +#ifndef __cplusplus + #ifndef __WCHAR_TYPE__ + #define __WCHAR_TYPE__ int32_t + #endif + typedef __WCHAR_TYPE__ wchar_t; +#endif // __cplusplus +#endif // _WCHAR_T + #include #define NULL 0 diff --git a/src/header/wchar/cbindgen.toml b/src/header/wchar/cbindgen.toml index a31881baad..e5b52de4d8 100644 --- a/src/header/wchar/cbindgen.toml +++ b/src/header/wchar/cbindgen.toml @@ -4,19 +4,9 @@ sys_includes = [ "features.h", ] after_includes = """ -// int32_t, uint32_t, WCHAR_MIN, WCHAR_MAX +// uint32_t, WCHAR_MIN, WCHAR_MAX #include -#ifndef _WCHAR_T -#define _WCHAR_T -#ifndef __cplusplus - #ifndef __WCHAR_TYPE__ - #define __WCHAR_TYPE__ int32_t - #endif - typedef __WCHAR_TYPE__ wchar_t; -#endif // __cplusplus -#endif // _WCHAR_T - #ifndef _WINT_T #define _WINT_T #ifndef __WINT_TYPE__