1 /******************************************************************************
3 * Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
23 #include "i2-base.hpp"
26 # define ASSERT(expr) ((void)0)
28 # define ASSERT(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__))
31 #define VERIFY(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__))
34 # define NORETURNPRE __declspec(noreturn)
40 # define NORETURNPOST __attribute__((noreturn))
45 NORETURNPRE int icinga_assert_fail(const char *expr, const char *file, int line) NORETURNPOST;
48 # pragma warning( push )
49 # pragma warning( disable : 4646 ) /* function declared with __declspec(noreturn) has non-void return type */
52 inline int icinga_assert_fail(const char *expr, const char *file, int line)
54 fprintf(stderr, "%s:%d: assertion failed: %s\n", file, line, expr);
57 #if !defined(__GNUC__) && !defined(_MSC_VER)
59 #endif /* !defined(__GNUC__) && !defined(_MSC_VER) */
63 # pragma warning( pop )