From 29ee6397a844e2d88f776f5c0b4e656e58df9840 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 7 Dec 2015 11:07:15 -0800 Subject: [PATCH] Fix stdio static initializers to make both clang and GCC happy. Previously only clang was happy. GCC said: error: missing initializer for field 'wcio_mbstate_in' of 'struct wchar_io_data' Change-Id: I25a11b64f4dfa22a5dd5daded152191fe2cfacaf --- libc/stdio/findfp.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libc/stdio/findfp.c b/libc/stdio/findfp.c index 35de07235..6e20562ce 100644 --- a/libc/stdio/findfp.c +++ b/libc/stdio/findfp.c @@ -52,10 +52,19 @@ _THREAD_PRIVATE_MUTEX(__sfp_mutex); +// TODO: when we no longer have to support both clang and GCC, we can simplify all this. +#define SBUF_INIT {0,0} +#if defined(__LP64__) +#define MBSTATE_T_INIT {{0},{0}} +#else +#define MBSTATE_T_INIT {{0}} +#endif +#define WCHAR_IO_DATA_INIT {MBSTATE_T_INIT,MBSTATE_T_INIT,{0},0,0} + static struct __sfileext __sFext[3] = { - { { NULL, 0 }, {}, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, false }, - { { NULL, 0 }, {}, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, false }, - { { NULL, 0 }, {}, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, false }, + { SBUF_INIT, WCHAR_IO_DATA_INIT, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, false }, + { SBUF_INIT, WCHAR_IO_DATA_INIT, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, false }, + { SBUF_INIT, WCHAR_IO_DATA_INIT, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, false }, }; // __sF is exported for backwards compatibility. Until M, we didn't have symbols