From 3ac6ef18481612df04013d9354d15376df2e785a Mon Sep 17 00:00:00 2001 From: oddcoder Date: Mon, 2 Mar 2020 00:06:49 +0200 Subject: [PATCH] Adjust stddef.h to be compatiable with other libc(s) I faced many issues when compiling libstdC++-V3 and linking against relibc mainly: - Missing types (max_align_t) - Different types definitions(ptrdiff_t , size_t) - and the fact that wchar_t is part of standard C++ and it seams that we canno redefine standard types --- include/stddef.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/stddef.h b/include/stddef.h index d9fbabd932..1ee56ff6f3 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -4,12 +4,20 @@ #define NULL 0 -typedef signed long long ptrdiff_t; +#ifndef __PTRDIFF_TYPE__ +#define __PTRDIFF_TYPE__ long int +#endif +typedef __PTRDIFF_TYPE__ ptrdiff_t; +#ifndef __cplusplus typedef int32_t wchar_t; +#endif /* #ifndef __cplusplus */ typedef int32_t wint_t; -typedef unsigned long long size_t; + +typedef long unsigned int size_t; + +typedef struct { long long __ll; long double __ld; } max_align_t; #define offsetof(type, member) __builtin_offsetof(type, member)