mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-22 10:50:07 +00:00
Use static_cast instead of C-style cast for C++.
This commit is contained in:
parent
0376962668
commit
fd20505248
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991,92,94,95,96,97,98,99,2000 Free Software Foundation, Inc.
|
/* Copyright (C) 1991,1992,1994-1999,2000,2001 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
# undef _ASSERT_H
|
# undef _ASSERT_H
|
||||||
# undef assert
|
# undef assert
|
||||||
|
# undef __ASSERT_VOID_CAST
|
||||||
|
|
||||||
# ifdef __USE_GNU
|
# ifdef __USE_GNU
|
||||||
# undef assert_perror
|
# undef assert_perror
|
||||||
@ -34,6 +35,12 @@
|
|||||||
#define _ASSERT_H 1
|
#define _ASSERT_H 1
|
||||||
#include <features.h>
|
#include <features.h>
|
||||||
|
|
||||||
|
#if defined __cplusplus && __GNUC_PREREQ (2,95)
|
||||||
|
# define __ASSERT_VOID_CAST static_cast<void>
|
||||||
|
#else
|
||||||
|
# define __ASSERT_VOID_CAST (void)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* void assert (int expression);
|
/* void assert (int expression);
|
||||||
|
|
||||||
If NDEBUG is defined, do nothing.
|
If NDEBUG is defined, do nothing.
|
||||||
@ -41,7 +48,7 @@
|
|||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
|
|
||||||
# define assert(expr) ((void) 0)
|
# define assert(expr) (__ASSERT_VOID_CAST (0))
|
||||||
|
|
||||||
/* void assert_perror (int errnum);
|
/* void assert_perror (int errnum);
|
||||||
|
|
||||||
@ -50,7 +57,7 @@
|
|||||||
(This is a GNU extension.) */
|
(This is a GNU extension.) */
|
||||||
|
|
||||||
# ifdef __USE_GNU
|
# ifdef __USE_GNU
|
||||||
# define assert_perror(errnum) ((void) 0)
|
# define assert_perror(errnum) (__ASSERT_VOID_CAST (0))
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#else /* Not NDEBUG. */
|
#else /* Not NDEBUG. */
|
||||||
@ -77,16 +84,16 @@ extern void __assert (const char *__assertion, const char *__file, int __line)
|
|||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
# define assert(expr) \
|
# define assert(expr) \
|
||||||
((void) ((expr) ? 0 : \
|
(__ASSERT_VOID_CAST ((expr) ? 0 : \
|
||||||
(__assert_fail (__STRING(expr), \
|
(__assert_fail (__STRING(expr), __FILE__, __LINE__, \
|
||||||
__FILE__, __LINE__, __ASSERT_FUNCTION), 0)))
|
__ASSERT_FUNCTION), 0)))
|
||||||
|
|
||||||
# ifdef __USE_GNU
|
# ifdef __USE_GNU
|
||||||
# define assert_perror(errnum) \
|
# define assert_perror(errnum) \
|
||||||
((void) (!(errnum) ? 0 : (__assert_perror_fail ((errnum), \
|
(__ASSERT_VOID_CAST (!(errnum) ? 0 : \
|
||||||
__FILE__, __LINE__, \
|
(__assert_perror_fail ((errnum), __FILE__, __LINE__, \
|
||||||
__ASSERT_FUNCTION), 0)))
|
__ASSERT_FUNCTION), 0)))
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
|
/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
|
||||||
|
Loading…
Reference in New Issue
Block a user