Jim Meyering wrote: > Eric Blake wrote: > >> Jim Meyering <jim <at> meyering.net> writes: >> >>> @@ -20,4 +20,4 @@ >>> #include <wchar.h> >>> >>> /* Internal state used by the functions mbsrtowcs() and mbsnrtowcs(). */ >>> -mbstate_t _gl_mbsrtowcs_state = 0; >>> +mbstate_t _gl_mbsrtowcs_state = { 0, }; >> Is this correct for all platforms? If I read Posix correctly, mbstate_t can >> be >> a numeric type rather than a struct. > > Good point. > Maybe we can use something like this instead: > > static mbstate_t _dummy; > mbstate_t _gl_mbsrtowcs_state = _dummy;
The {0,} init method works for scalar or aggregate types: http://www.pixelbeat.org/programming/gcc/auto_init.html Though as noted there, may give warnings. cheers, Pádraig.