From e329b7226bc344af8259fd4722682a7b39a0896e Mon Sep 17 00:00:00 2001 From: Bert Vandenbroucke <vandenbroucke@strw.leidenuniv.nl> Date: Tue, 30 Nov 2021 09:12:40 +0100 Subject: [PATCH] Added warning macro that flushes immediately and writes to the standard error. --- src/error.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/error.h b/src/error.h index de4e9fa44c..900d7e1bdd 100644 --- a/src/error.h +++ b/src/error.h @@ -131,6 +131,28 @@ extern int engine_rank; }) #endif +/** + * @brief Macro to print a localized warning message with variable arguments. + * + * Same as message(), but this version prints to the standard error and is + * flushed immediately. + * + */ +#ifdef WITH_MPI +extern int engine_rank; +#define warning(s, ...) \ + ({ \ + fprintf(stderr, "[%04i] %s %s: WARNING: " s "\n", engine_rank, \ + clocks_get_timesincestart(), __FUNCTION__, ##__VA_ARGS__); \ + }) +#else +#define warning(s, ...) \ + ({ \ + fprintf(stderr, "%s %s: WARNING: " s "\n", clocks_get_timesincestart(), \ + __FUNCTION__, ##__VA_ARGS__); \ + }) +#endif + /** * @brief Assertion macro compatible with MPI * -- GitLab