Problem with wchar.h, _FORTIFY_SOURCE , and -std=c99

Ken Brown kbrown@cornell.edu
Tue Mar 13 18:10:00 GMT 2018


$ cat test.c
#include <wchar.h>

$ gcc -std=c99 -O2 -Wp,-D_FORTIFY_SOURCE=2 -c test.c
In file included from /usr/include/ssp/wchar.h:5:0,
                  from /usr/include/wchar.h:336,
                  from test.c:1:
/usr/include/ssp/wchar.h:78:1: error: unknown type name ‘FILE’
  __ssp_decl(wchar_t *, fgetws, (wchar_t *__restrict __buf, int __wlen, 
FILE *__restrict __fp))
  ^
/usr/include/ssp/wchar.h:78:1: error: unknown type name ‘FILE’
  __ssp_decl(wchar_t *, fgetws, (wchar_t *__restrict __buf, int __wlen, 
FILE *__restrict __fp))
  ^

If I drop '-std=c99', the problem goes away because FILE is defined in 
/usr/include/wchar.h prior to the inclusion of /usr/include/ssp/wchar.h.

If I drop '-Wp,-D_FORTIFY_SOURCE=2', the problem goes away because 
/usr/include/wchar.h doesn't use FILE; it only uses __FILE.

Should /usr/include/ssp/wchar.h be changed to similarly avoid FILE?

Ken



More information about the Newlib mailing list