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

Yaakov Selkowitz yselkowitz@cygwin.com
Wed Mar 14 15:48:00 GMT 2018


On 2018-03-13 13:10, Ken Brown wrote:
> $ 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?

Yes, I checked in a patch.

-- 
Yaakov

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/newlib/attachments/20180314/a29c184b/attachment.sig>


More information about the Newlib mailing list