From 14b5544d8b6d72c1e11e9732f42502fb9003700a Mon Sep 17 00:00:00 2001 From: "Victor A. P. Magri" <50467563+victorapm@users.noreply.github.com> Date: Tue, 17 Oct 2023 10:28:34 -0400 Subject: [PATCH] Fix regressions (#988) * CMake uses C99 by default * HYPRE_PRINT_INDENT works without a loop --- src/CMakeLists.txt | 3 +++ src/utilities/_hypre_utilities.h | 6 ++---- src/utilities/matrix_stats.h | 6 ++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dabcb35ef..00322ba6b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,6 +24,9 @@ project(${PROJECT_NAME} VERSION ${HYPRE_VERSION} LANGUAGES C) +# We use C99 by default, but users are free to specify any newer standard version +set(CMAKE_C_STANDARD 99) + if (${HYPRE_SOURCE_DIR} STREQUAL ${HYPRE_BINARY_DIR}) message(FATAL_ERROR "In-place build not allowed! Please use a separate build directory. See the Users Manual or INSTALL file for details.") endif () diff --git a/src/utilities/_hypre_utilities.h b/src/utilities/_hypre_utilities.h index 11f064f5a..2a9ae9080 100644 --- a/src/utilities/_hypre_utilities.h +++ b/src/utilities/_hypre_utilities.h @@ -395,10 +395,8 @@ typedef struct hypre_MatrixStatsArray_struct hypre_printf(" %s\n", msg); #define HYPRE_PRINT_INDENT(n) \ - for (HYPRE_Int __i = 0; __i < n; __i++) \ - { \ - hypre_printf(" "); \ - } + hypre_printf("%*s", (n > 0) ? n : 0, ""); + #define HYPRE_PRINT_SHIFTED_PARAM(n, ...) \ HYPRE_PRINT_INDENT(n) \ diff --git a/src/utilities/matrix_stats.h b/src/utilities/matrix_stats.h index 925610100..e583868ed 100644 --- a/src/utilities/matrix_stats.h +++ b/src/utilities/matrix_stats.h @@ -118,10 +118,8 @@ typedef struct hypre_MatrixStatsArray_struct hypre_printf(" %s\n", msg); #define HYPRE_PRINT_INDENT(n) \ - for (HYPRE_Int __i = 0; __i < n; __i++) \ - { \ - hypre_printf(" "); \ - } + hypre_printf("%*s", (n > 0) ? n : 0, ""); + #define HYPRE_PRINT_SHIFTED_PARAM(n, ...) \ HYPRE_PRINT_INDENT(n) \