From 0bb66cff740ddab4306621f1784ae2bc68221ff1 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Wed, 23 Aug 2023 14:53:15 -0700 Subject: [PATCH] change int.h to check MAJOR_VER < 3 when CHK_C is undefined The int.h will trigger an error when CHK_C is undefined and MAJOR_VER >= 3. Improved the int.h error message in this case. Added some comments and C integers to int.h. --- CHANGES | 2 +- int.h | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index cba813f..07eddd4 100644 --- a/CHANGES +++ b/CHANGES @@ -72,7 +72,7 @@ The following are the changes from calc version 2.14.3.5 to date: appear to meet calc requirements, or undefines CHK_C when it does not. - Added int.h as a centeral place for calc integer types and + Added int.h as a central place for calc integer types and integer macros. diff --git a/int.h b/int.h index 314350a..d610cab 100644 --- a/int.h +++ b/int.h @@ -1,6 +1,11 @@ /* * int - integer types and integer macros used in calc * + * For general information on C integers, see: + * + * https://en.cppreference.com/w/c/language/arithmetic_types + * https://en.cppreference.com/w/c/types/integer + * * Copyright (C) 2023 Landon Curt Noll * * Primary author: Landon Curt Noll @@ -119,7 +124,6 @@ #endif /* UINTMAX_WIDTH */ - /* * case: C compiler and/or select include files do not meet calc requirements */ @@ -130,7 +134,7 @@ * calc v2 is the last version where one might be able to use an old C compiler * and/or tolerate missing include files */ -#if defined(CALC2_COMPAT) +#if MAJOR_VER < 3 /* @@ -195,18 +199,16 @@ #endif /* UINTMAX_WIDTH */ - -#else /* CALC2_COMPAT */ +#else /* MAJOR_VER < 3 */ /* - * CHK_C undefuned and not calc v2 is an error + * calc v3 or later and CHK_C is undefined */ -#pragma GCC error "CHK_C undefined: C compiler and/or select include files do not meet calc requirements" -#pragma GCC error "CALC2_COMPAT undefined: calc v3 and later requires CHK_C" +#pragma GCC error "calc v3 and later require C compiler and include files that support CHK_C" -#endif /* CALC2_COMPAT */ +#endif /* MAJOR_VER < 3 */ #endif /* CHK_C */