From d29196a493b0d63ea543af2cab1db062ae39fce2 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 26 Apr 2022 10:59:50 -0400 Subject: use C2x style header versioning for include guards --- complex.h | 14 +++++++++----- ctype.h | 10 +++++++--- errno.h | 46 ++++++++++++++-------------------------------- fenv.h | 10 +++++++--- float.h | 10 +++++++--- inttypes.h | 10 +++++++--- iso646.h | 10 +++++++--- limits.h | 10 +++++++--- locale.h | 10 +++++++--- math.h | 8 ++++++-- stdarg.h | 8 ++++++-- stdbool.h | 8 ++++++-- stddef.h | 8 ++++++-- stdint.h | 8 ++++++-- stdio.h | 8 ++++++-- stdlib.h | 8 ++++++-- string.h | 8 ++++++-- time.h | 8 ++++++-- wchar.h | 8 ++++++-- wctype.h | 8 ++++++-- 20 files changed, 138 insertions(+), 80 deletions(-) diff --git a/complex.h b/complex.h index 55a2d71..8965f38 100644 --- a/complex.h +++ b/complex.h @@ -1,5 +1,9 @@ -#ifndef __COMPLEX_H__ -#define __COMPLEX_H__ +#ifndef __STDC_VERSION_COMPLEX_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_COMPLEX_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_COMPLEX_H__ 1 +#endif /* UNG's Not GNU @@ -27,11 +31,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#if !(defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__) +#if (__STDC_VERSION_COMPLEX_H__ < 199901L) #error " requires C99 or higher" #endif -#if (defined __STDC_NO_COMPLES__) +#if (defined __STDC_NO_COMPLEX__) #error " requies compiler support" #endif @@ -53,7 +57,7 @@ SOFTWARE. float _Complex __c; \ float __f[2]; \ }){ .__f = { 0.0, 1.0 } }).__c) -#if (201112L <= __STDC_VERSION__) +#if (201112L <= __STDC_VERSION_COMPLEX_H__) # ifdef __STDC_IEC_559_COMPLEX__ # define CMPLX(__x, __y) \ ((double complex)((double)(__x) + _Imaginary_I * (double)(__y))) diff --git a/ctype.h b/ctype.h index 97e4351..6d5cf77 100644 --- a/ctype.h +++ b/ctype.h @@ -1,5 +1,9 @@ -#ifndef __CTYPE_H__ -#define __CTYPE_H__ +#ifndef __STDC_VERSION_CTYPE_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_CTYPE_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_CTYPE_H__ 1 +#endif /* UNG's Not GNU @@ -43,7 +47,7 @@ int isxdigit(int); int tolower(int); int toupper(int); -#if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__) +#if (199901L <= __STDC_VERSION_CTYPE_H__) int isblank(int); #endif diff --git a/errno.h b/errno.h index 5c0c181..ac243eb 100644 --- a/errno.h +++ b/errno.h @@ -1,5 +1,9 @@ -#ifndef __ERRNO_H__ -#define __ERRNO_H__ +#ifndef __STDC_VERSION_ERRNO_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_ERRNO_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_ERRNO_H__ 1 +#endif /* UNG's Not GNU @@ -27,44 +31,21 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#if defined _XOPEN_SOURCE && _XOPEN_SOURCE - 1 < 0 -#undef _XOPEN_SOURCE -#define _XOPEN_SOURCE 400 -#endif - -#if defined _XOPEN_SOURCE && !defined _POSIX_C_SOURCE -# if (_XOPEN_SOURCE >= 700) -# define _POSIX_C_SOURCE 200809L -# elif (_XOPEN_SOURCE >= 600) -# define _POSIX_C_SOURCE 200112L -# elif (_XOPEN_SOURCE >= 500) -# define _POSIX_C_SOURCE 199506L -# else -# define _POSIX_C_SOURCE 2 -# endif -#endif - -#if defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE -# define _POSIX_SOURCE -#endif - -#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 19901L -# if (defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 200112L) -# error POSIX.1-2001 and later require a C99 compiler -# elif (defined _XOPEN_SOURCE && _XOPEN_SOURCE >= 600) -# error XOPEN Issue 6 and later require a C99 compiler -# endif -#endif +/* TODO: XOPEN/POSIX/etc. */ #define EDOM (1) #define ERANGE (2) #define errno (*__errno()) -#if (defined __STDC_VERSION__ && 199409 <= __STDC_VERSION__) +#if (199504L <= __STDC_VERSION_ERRNO_H__) #define EILSEQ (3) #endif -#if (defined _POSIX_SOURCE) +#if (201107L <= __STDC_VERSION_ERRNO_H__ && defined __STDC_WANT_LIB_EXT1__) +typedef int errno_t; +#endif + +#if (defined _POSIX_SOURCE) #define E2BIG (10) #define EACCES (11) #define EAGAIN (12) @@ -97,6 +78,7 @@ SOFTWARE. #define EPERM (39) #define EPIPE (40) #define EROFS (41) +#define ESPIPE (42) #define ESRCH (43) #define EXDEV (44) #endif diff --git a/fenv.h b/fenv.h index f7b78f6..d5af9fe 100644 --- a/fenv.h +++ b/fenv.h @@ -1,5 +1,9 @@ -#ifndef __FENV_H__ -#define __FENV_H__ +#ifndef __STDC_VERSION_FENV_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_FENV_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_FENV_H__ 1 +#endif /* UNG's Not GNU @@ -27,7 +31,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#if !(defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__) +#if (__STDC_VERSION_FENV_H__ < 199901L) # error " requires C99 or higher" #endif diff --git a/float.h b/float.h index fb7e1f2..69b6744 100644 --- a/float.h +++ b/float.h @@ -1,5 +1,9 @@ -#ifndef __FLOAT_H__ -#define __FLOAT_H__ +#ifndef __STDC_VERSION_FLOAT_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_FLOAT_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_FLOAT_H__ 1 +#endif /* UNG's Not GNU @@ -57,7 +61,7 @@ SOFTWARE. #define LDBL_MIN_10_EXP (-37) #define LDBL_MIN_EXP (-1021) -#if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__) +#if (199901L <= __STDC_VERSION_FLOAT_H__) #define DECIMAL_DIG (10) #define FLT_EVAL_METHOD (-1) #endif diff --git a/inttypes.h b/inttypes.h index eb52fd6..006ba76 100644 --- a/inttypes.h +++ b/inttypes.h @@ -1,5 +1,9 @@ -#ifndef __INTTYPES_H__ -#define __INTTYPES_H__ +#ifndef __STDC_VERSION_INTTYPES_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_INTTYPES_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_INTTYPES_H__ 1 +#endif /* UNG's Not GNU @@ -29,7 +33,7 @@ SOFTWARE. /* TODO: replace WORD_BIT with __LP32__, __ILP32__, __ILP64__, __LLP64__ */ -#if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__) +#if (199901L <= __STDC_VERSION_INTTYPES_H__) #include #define PRIX16 "hX" diff --git a/iso646.h b/iso646.h index 2e40179..660625f 100644 --- a/iso646.h +++ b/iso646.h @@ -1,5 +1,9 @@ -#ifndef __ISO646_H__ -#define __ISO646_H__ +#ifndef __STDC_VERSION_ISO646_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_ISO646_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_ISO646_H__ 1 +#endif /* UNG's Not GNU @@ -27,7 +31,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#if !(defined __STDC_VERSION__ && 199409L <= __STDC_VERSION__) +#if (__STDC_VERSION_ISO646_H__ < 199409L) # error requires C95 or higher #endif diff --git a/limits.h b/limits.h index 49a754c..d8a39b3 100644 --- a/limits.h +++ b/limits.h @@ -1,5 +1,9 @@ -#ifndef __LIMITS_H__ -#define __LIMITS_H__ +#ifndef __STDC_VERSION_LIMITS_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_LIMITS_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_LIMITS_H__ 1 +#endif /* UNG's Not GNU @@ -68,7 +72,7 @@ SOFTWARE. #define UCHAR_MAX (255) #define USHRT_MAX (65535) -#if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__) +#if (199901L <= __STDC_VERSION_LIMITS_H__) #define LLONG_MAX (9223372036854775807LL) #define LLONG_MIN (-LLONG_MAX - 1LL) #define ULLONG_MAX (18446744073709551615ULL) diff --git a/locale.h b/locale.h index 4fb8f60..5a6644b 100644 --- a/locale.h +++ b/locale.h @@ -1,5 +1,9 @@ -#ifndef __LOCALE_H__ -#define __LOCALE_H__ +#ifndef __STDC_VERSION_LOCALE_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_LOCALE_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_LOCALE_H__ 1 +#endif /* UNG's Not GNU @@ -63,7 +67,7 @@ struct lconv { char n_sep_by_space; char p_sign_posn; char n_sign_posn; - #if __STDC_VERSION__ >= 199901L + #if __STDC_VERSION_LOCALE_H__ >= 199901L char int_p_cs_precedes; char int_p_sep_by_space; char int_n_cs_precedes; diff --git a/math.h b/math.h index 428990b..7e69ae0 100644 --- a/math.h +++ b/math.h @@ -1,5 +1,9 @@ -#ifndef __MATH_H__ -#define __MATH_H__ +#ifndef __STDC_VERSION_MATH_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_MATH_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_MATH_H__ 1 +#endif /* UNG's Not GNU diff --git a/stdarg.h b/stdarg.h index a1abc94..cde9cf5 100644 --- a/stdarg.h +++ b/stdarg.h @@ -1,5 +1,9 @@ -#ifndef __STDARG_H__ -#define __STDARG_H__ +#ifndef __STDC_VERSION_STDARG_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_STDARG_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_STDARG_H__ 1 +#endif /* UNG's Not GNU diff --git a/stdbool.h b/stdbool.h index 46d637e..c6edc08 100644 --- a/stdbool.h +++ b/stdbool.h @@ -1,5 +1,9 @@ -#ifndef __STDBOOL_H__ -#define __STDBOOL_H__ +#ifndef __STDC_VERSION_STDBOOL_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_STDBOOL_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_STDBOOL_H__ 1 +#endif /* UNG's Not GNU diff --git a/stddef.h b/stddef.h index 03f648d..637499c 100644 --- a/stddef.h +++ b/stddef.h @@ -1,5 +1,9 @@ -#ifndef __STDDEF_H__ -#define __STDDEF_H__ +#ifndef __STDC_VERSION_STDDEF_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_STDDEF_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_STDDEF_H__ 1 +#endif /* UNG's Not GNU diff --git a/stdint.h b/stdint.h index b116f05..6313efe 100644 --- a/stdint.h +++ b/stdint.h @@ -1,5 +1,9 @@ -#ifndef __STDINT_H__ -#define __STDINT_H__ +#ifndef __STDC_VERSION_STDINT_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_STDINT_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_STDINT_H__ 1 +#endif /* UNG's Not GNU diff --git a/stdio.h b/stdio.h index 964ee74..d910fe8 100644 --- a/stdio.h +++ b/stdio.h @@ -1,5 +1,9 @@ -#ifndef __STDIO_H__ -#define __STDIO_H__ +#ifndef __STDC_VERSION_STDIO_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_STDIO_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_STDIO_H__ 1 +#endif /* UNG's Not GNU diff --git a/stdlib.h b/stdlib.h index 9350398..54e43df 100644 --- a/stdlib.h +++ b/stdlib.h @@ -1,5 +1,9 @@ -#ifndef __STDLIB_H__ -#define __STDLIB_H__ +#ifndef __STDC_VERSION_STDLIB_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_STDLIB_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_STDLIB_H__ 1 +#endif /* UNG's Not GNU diff --git a/string.h b/string.h index a802782..a5138fd 100644 --- a/string.h +++ b/string.h @@ -1,5 +1,9 @@ -#ifndef __STRING_H__ -#define __STRING_H__ +#ifndef __STDC_VERSION_STRING_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_STRING_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_STRING_H__ 1 +#endif /* UNG's Not GNU diff --git a/time.h b/time.h index 8f9c47a..5fede75 100644 --- a/time.h +++ b/time.h @@ -1,5 +1,9 @@ -#ifndef __TIME_H__ -#define __TIME_H__ +#ifndef __STDC_VERSION_TIME_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_TIME_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_TIME_H__ 1 +#endif /* UNG's Not GNU diff --git a/wchar.h b/wchar.h index 934181f..ef58065 100644 --- a/wchar.h +++ b/wchar.h @@ -1,5 +1,9 @@ -#ifndef __WCHAR_H__ -#define __WCHAR_H__ +#ifndef __STDC_VERSION_WCHAR_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_WCHAR_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_WCHAR_H__ 1 +#endif /* UNG's Not GNU diff --git a/wctype.h b/wctype.h index 139d77a..f89a6a0 100644 --- a/wctype.h +++ b/wctype.h @@ -1,5 +1,9 @@ -#ifndef __WCTYPE_H__ -#define __WCTYPE_H__ +#ifndef __STDC_VERSION_WCTYPE_H__ +#if defined __STDC_VERSION__ +#define __STDC_VERSION_WCTYPE_H__ __STDC_VERSION__ +#else +#define __STDC_VERSION_WCTYPE_H__ 1 +#endif /* UNG's Not GNU -- cgit v1.2.1