1 wchar.h: only include other headers if _FORTIFY_SOURCE is enabled
3 unexpectedly including other headers can cause problems with
4 sensitive/brittle code, particularly with alternative compilers
5 (clang) which are already operating on the margins of what's
6 supported/expected by some projects.
8 having a way to almost entirely short-circuit these headers (by
9 disabling _FORTIFY_SOURCE) is therefore important.
11 --- a/include/fortify/wchar.h
12 +++ b/include/fortify/wchar.h
14 #if !defined(__cplusplus) && !defined(__clang__)
17 -#include_next <limits.h>
18 +#include_next <wchar.h>
20 +#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
22 #if !defined(__cplusplus) && !defined(__clang__)
25 -#include_next <stdlib.h>
26 +#include_next <limits.h>
27 #if !defined(__cplusplus) && !defined(__clang__)
30 -#include_next <string.h>
31 +#include_next <stdlib.h>
32 #if !defined(__cplusplus) && !defined(__clang__)
35 -#include_next <wchar.h>
36 +#include_next <string.h>
38 -#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
39 #include "fortify-headers.h"