getaddrinfo.c: Avoid misleading indentation warning
[uclibc-ng.git] / include / assert.h
blobfd71e833bcb533e09e069db210369a843c87b31e
1 /* Copyright (C) 1991,1992,1994-2001,2003,2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 * ISO C99 Standard: 7.2 Diagnostics <assert.h>
22 #ifdef _ASSERT_H
24 # undef _ASSERT_H
25 # undef assert
26 # undef __ASSERT_VOID_CAST
28 #endif /* assert.h */
30 #define _ASSERT_H 1
31 #include <features.h>
33 #if defined __cplusplus && __GNUC_PREREQ (2,95)
34 # define __ASSERT_VOID_CAST static_cast<void>
35 #else
36 # define __ASSERT_VOID_CAST (void)
37 #endif
39 /* void assert (int expression);
41 If NDEBUG is defined, do nothing.
42 If not, and EXPRESSION is zero, print an error message and abort. */
44 #ifdef NDEBUG
46 # define assert(expr) (__ASSERT_VOID_CAST (0))
48 #else /* Not NDEBUG. */
50 __BEGIN_DECLS
52 /* This prints an "Assertion failed" message and aborts. */
53 extern void __assert(const char *, const char *, unsigned int, const char *)
54 __THROW __attribute__ ((__noreturn__));
55 libc_hidden_proto(__assert)
57 __END_DECLS
59 # define assert(expr) \
60 (__ASSERT_VOID_CAST ((expr) ? 0 : \
61 (__assert (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION), 0)))
63 /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
64 which contains the name of the function currently being defined.
65 This is broken in G++ before version 2.6.
66 C9x has a similar variable called __func__, but prefer the GCC one since
67 it demangles C++ function names. */
68 # if defined __cplusplus ? __GNUC_PREREQ (2, 6) : __GNUC_PREREQ (2, 4)
69 # define __ASSERT_FUNCTION __PRETTY_FUNCTION__
70 # else
71 # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
72 # define __ASSERT_FUNCTION __func__
73 # else
74 # define __ASSERT_FUNCTION ((const char *) 0)
75 # endif
76 # endif
78 #endif /* NDEBUG. */
80 #if defined __USE_ISOC11 && !defined __cplusplus
81 # undef static_assert
82 # define static_assert _Static_assert
83 #endif