The MinGW.org Windows System Libraries
リビジョン | f186d677f9cb6eb23ecaaaf60e35a69a42c6a82e (tree) |
---|---|
日時 | 2017-01-29 19:09:49 |
作者 | Keith Marshall <keithmarshall@user...> |
コミッター | Keith Marshall |
Expose C99 features required by C++11; fix issue [#2335]
@@ -1,3 +1,20 @@ | ||
1 | +2017-01-29 Keith Marshall <keithmarshall@users.sourceforge.net> | |
2 | + | |
3 | + Expose C99 features required by C++11; fix issue [#2335] | |
4 | + | |
5 | + * include/_mingw.h.in (_ISOC99_SOURCE): Ensure it is defined for... | |
6 | + [__cplusplus >= 201103L]: ...this conformance level, in addition to... | |
7 | + [__STDC_VERSION__>= 199901L || _POSIX_C_SOURCE >= 200112L]: ...these. | |
8 | + [_GLIBCXX_USE_C99]: Force it for -std=c++11, subject to... | |
9 | + [__GNUC__ < 6]: ...this. | |
10 | + | |
11 | + * include/ctype.h (isblank): Declare it only if... | |
12 | + [_ISOC99_SOURCE]: ...this, thus simplifying declarative condition. | |
13 | + * include/wctype.h (iswblank) [_ISOC99_SOURCE]: Likewise. | |
14 | + * include/inttypes.h (SCNd8, SCNdLEAST8, SCNdFAST8, SCNi8, SCNiLEAST8) | |
15 | + (SCNiFAST8, SCNo8, SCNoLEAST8, SCNoFAST8, SCNx8, SCNxLEAST8, SCNxFAST8) | |
16 | + (SCNu8, SCNuLEAST8, SCNuFAST8) [_ISOC99_SOURCE]: Likewise. | |
17 | + | |
1 | 18 | 2017-01-28 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 19 | |
3 | 20 | Make strnlen() and wcsnlen() declaratively consistent. |
@@ -8,7 +8,7 @@ | ||
8 | 8 | * $Id$ |
9 | 9 | * |
10 | 10 | * Written by Mumit Khan <khan@xraylith.wisc.edu> |
11 | - * Copyright (C) 1999, 2001-2011, 2014-2016, MinGW.org Project | |
11 | + * Copyright (C) 1999, 2001-2011, 2014-2017, MinGW.org Project | |
12 | 12 | * |
13 | 13 | * |
14 | 14 | * Permission is hereby granted, free of charge, to any person obtaining a |
@@ -451,18 +451,62 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case. */ | ||
451 | 451 | /* libmingwex.a provides free-standing implementations for many of the |
452 | 452 | * functions which were introduced in C99; MinGW headers do not expose |
453 | 453 | * prototypes for these, unless this feature test macro is defined, by |
454 | - * the user, or implied by other standards... | |
454 | + * the user, or implied by other standards. We will use a bit-mapped | |
455 | + * representation, comprising the bit-wise sum of: | |
456 | + * | |
457 | + * 0x08 user declared | |
458 | + * 0x04 required by C compiler, supporting ISO-C99 | |
459 | + * 0x02 required by C++ compiler, supporting ISO-C++11 | |
460 | + * 0x01 required to support recent POSIX.1 features | |
461 | + * | |
462 | + * to ensure that we can identify the reason for implicit declaration, | |
463 | + * (in the event that we may need to discriminate). | |
455 | 464 | */ |
456 | -# if __STDC_VERSION__ >= 199901L || _POSIX_C_SOURCE >= 200112L | |
457 | -# define _ISOC99_SOURCE 1 | |
465 | +# if __STDC_VERSION__ >= 199901L | |
466 | + /* This represents a compiler supporting ISO-C99; enable all potential | |
467 | + * use of ISO-C99 features, (to the maximum extent supportable), which | |
468 | + * presumably also covers all C++11 and POSIX.1 usage. | |
469 | + */ | |
470 | +# define _ISOC99_SOURCE 0x07 | |
471 | + | |
472 | +# elif __cplusplus >= 201103L | |
473 | + /* C++11 also incorporates many (if not all) of the ISO-C99 features, | |
474 | + * which we have guarded by _ISOC99_SOURCE; enable such features, to | |
475 | + * the required extent, (which is likely also sufficient to support | |
476 | + * any POSIX.1 dependencies). | |
477 | + */ | |
478 | +# define _ISOC99_SOURCE 0x03 | |
479 | + | |
480 | +# elif _POSIX_C_SOURCE >= 200112L | |
481 | + /* This represents the minimum level of ISO-C99 support, which may be | |
482 | + * required by POSIX.1, (and which may be no less than full support). | |
483 | + */ | |
484 | +# define _ISOC99_SOURCE 0x01 | |
458 | 485 | # endif |
486 | + | |
487 | +#else | |
488 | + /* The the user has explicitly declared a source level dependency on | |
489 | + * ISO-C99 features; regardless of how it was declared, redefine it to | |
490 | + * ensure that any plausible dependency is covered. | |
491 | + */ | |
492 | +# undef _ISOC99_SOURCE | |
493 | +# define _ISOC99_SOURCE 0x0F | |
494 | + | |
495 | +#endif /* _ISOC99_SOURCE */ | |
496 | + | |
497 | +#if _ISOC99_SOURCE && __cplusplus >= 201103L && __GNUC__ < 6 | |
498 | + /* Due to a configuration defect in GCC versions prior to GCC-6, when | |
499 | + * compiling C++11 code, the ISO-C99 functions may not be incorporated | |
500 | + * into the appropriate namespace(s); we may be able to mitigate this, | |
501 | + * by ensuring that this GCC configuration macro is defined. | |
502 | + */ | |
503 | +# define _GLIBCXX_USE_C99 1 | |
459 | 504 | #endif |
460 | 505 | |
461 | 506 | #if ! defined _MINGW32_SOURCE_EXTENDED && ! defined __STRICT_ANSI__ |
462 | -/* | |
463 | - * Enable mingw32 extensions by default, except when __STRICT_ANSI__ | |
464 | - * conformity mode has been enabled. | |
465 | - */ | |
507 | + /* Enable mingw32 extensions by default, except when __STRICT_ANSI__ | |
508 | + * conformity mode has been enabled. | |
509 | + */ | |
466 | 510 | # define _MINGW32_SOURCE_EXTENDED 1 |
467 | 511 | #endif |
468 | 512 |
@@ -80,7 +80,7 @@ _CRTIMP __cdecl __MINGW_NOTHROW int isspace(int); | ||
80 | 80 | _CRTIMP __cdecl __MINGW_NOTHROW int isupper(int); |
81 | 81 | _CRTIMP __cdecl __MINGW_NOTHROW int isxdigit(int); |
82 | 82 | |
83 | -#if __STDC_VERSION__ >= 199901L || !defined __STRICT_ANSI__ | |
83 | +#if _ISOC99_SOURCE | |
84 | 84 | __cdecl __MINGW_NOTHROW int isblank (int); |
85 | 85 | #endif |
86 | 86 |
@@ -217,7 +217,7 @@ __CRT_INLINE __cdecl __MINGW_NOTHROW int isupper (int c) | ||
217 | 217 | __CRT_INLINE __cdecl __MINGW_NOTHROW int isxdigit (int c) |
218 | 218 | { return __ISCTYPE(c, _HEX); } |
219 | 219 | |
220 | -#if __STDC_VERSION__ >= 199901L || !defined __STRICT_ANSI__ | |
220 | +#if _ISOC99_SOURCE | |
221 | 221 | __CRT_INLINE __cdecl __MINGW_NOTHROW int isblank (int c) |
222 | 222 | { return (__ISCTYPE(c, _BLANK) || c == '\t'); } |
223 | 223 | #endif |
@@ -222,10 +222,12 @@ typedef struct { | ||
222 | 222 | #define SCNuMAX "I64u" |
223 | 223 | #define SCNuPTR "u" |
224 | 224 | |
225 | -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L | |
226 | -/* | |
227 | - * no length modifier for char types prior to C9x | |
228 | - * MS runtime scanf appears to treat "hh" as "h" | |
225 | +#if _ISOC99_SOURCE | |
226 | +/* Defined by the user, or implicitly in <_mingw.h>, indicating that | |
227 | + * we are compiling for C99, C++11, or POSIX.1-2001 (or later); no char | |
228 | + * type length modifiers are supported prior to C99. Further note that | |
229 | + * Microsoft's scanf() appears to treat the ISO-C99/POSIX.1 "hh" length | |
230 | + * modifier as if it were just "h". | |
229 | 231 | */ |
230 | 232 | |
231 | 233 | /* signed char */ |
@@ -249,7 +251,7 @@ typedef struct { | ||
249 | 251 | #define SCNu8 "hhu" |
250 | 252 | #define SCNuLEAST8 "hhu" |
251 | 253 | #define SCNuFAST8 "hhu" |
252 | -#endif /* __STDC_VERSION__ >= 199901 */ | |
254 | +#endif /* _ISOC99_SOURCE */ | |
253 | 255 | |
254 | 256 | #endif /* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */ |
255 | 257 |
@@ -6,7 +6,7 @@ | ||
6 | 6 | * $Id$ |
7 | 7 | * |
8 | 8 | * Written by Mumit Khan <khan@xraylith.wisc.edu> |
9 | - * Copyright (C) 1999-2003, 2005-2007, 2016, MinGW.org Project | |
9 | + * Copyright (C) 1999-2003, 2005-2007, 2016, 2017, MinGW.org Project | |
10 | 10 | * |
11 | 11 | * |
12 | 12 | * Permission is hereby granted, free of charge, to any person obtaining a |
@@ -119,7 +119,7 @@ __MINGW_ATTRIB_DEPRECATED | ||
119 | 119 | */ |
120 | 120 | _CRTIMP __cdecl __MINGW_NOTHROW int is_wctype (wint_t, wctype_t); |
121 | 121 | |
122 | -#if __STDC_VERSION__>=199901L || !defined __STRICT_ANSI__ || defined __cplusplus | |
122 | +#if _ISOC99_SOURCE | |
123 | 123 | __cdecl __MINGW_NOTHROW int iswblank (wint_t); |
124 | 124 | #endif |
125 | 125 |
@@ -173,7 +173,7 @@ __CRT_INLINE __cdecl __MINGW_NOTHROW int iswupper (wint_t wc) | ||
173 | 173 | __CRT_INLINE __cdecl __MINGW_NOTHROW int iswxdigit (wint_t wc) |
174 | 174 | { return (iswctype (wc, _HEX)); } |
175 | 175 | |
176 | -#if __STDC_VERSION__>=199901L || !defined __STRICT_ANSI__ || defined __cplusplus | |
176 | +#if _ISOC99_SOURCE | |
177 | 177 | __CRT_INLINE __cdecl __MINGW_NOTHROW int iswblank (wint_t wc) |
178 | 178 | { return (iswctype (wc, _BLANK) || wc == L'\t'); } |
179 | 179 | #endif |