diff options
Diffstat (limited to 'src/include/gnunet_common.h')
-rw-r--r-- | src/include/gnunet_common.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index df1ccff26..8cfeab1cc 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2006-2020 GNUnet e.V. | 3 | Copyright (C) 2006-2021 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -875,10 +875,14 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
875 | * @ingroup logging | 875 | * @ingroup logging |
876 | * Use this for fatal errors that cannot be handled | 876 | * Use this for fatal errors that cannot be handled |
877 | */ | 877 | */ |
878 | #if __GNUC__ >= 6 || __clang_major__ >= 6 | ||
878 | #define GNUNET_assert(cond) \ | 879 | #define GNUNET_assert(cond) \ |
879 | do \ | 880 | do \ |
880 | { \ | 881 | { \ |
882 | _Pragma("GCC diagnostic push") \ | ||
883 | _Pragma("GCC diagnostic ignored \"-Wtautological-compare\"") \ | ||
881 | if (! (cond)) \ | 884 | if (! (cond)) \ |
885 | _Pragma("GCC diagnostic pop") \ | ||
882 | { \ | 886 | { \ |
883 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ | 887 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ |
884 | _ ("Assertion failed at %s:%d. Aborting.\n"), \ | 888 | _ ("Assertion failed at %s:%d. Aborting.\n"), \ |
@@ -887,7 +891,21 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
887 | GNUNET_abort_ (); \ | 891 | GNUNET_abort_ (); \ |
888 | } \ | 892 | } \ |
889 | } while (0) | 893 | } while (0) |
890 | 894 | #else | |
895 | /* older GCC/clangs do not support -Wtautological-compare */ | ||
896 | #define GNUNET_assert(cond) \ | ||
897 | do \ | ||
898 | { \ | ||
899 | if (! (cond)) \ | ||
900 | { \ | ||
901 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ | ||
902 | _ ("Assertion failed at %s:%d. Aborting.\n"), \ | ||
903 | __FILE__, \ | ||
904 | __LINE__); \ | ||
905 | GNUNET_abort_ (); \ | ||
906 | } \ | ||
907 | } while (0) | ||
908 | #endif | ||
891 | 909 | ||
892 | /** | 910 | /** |
893 | * @ingroup logging | 911 | * @ingroup logging |