G
Giannis Papadopoulos
I want to create a macro that it must be ignored when NDEBUG is defined.
The macro I've created is
#ifndef NDEBUG
# define ERROR_MESSAGE(s) fprintf(stderr, "%s(): %s\n", __func__, (s));
#else
# define ERROR_MESSAGE(s)
#endif
However, when I checked assert.h to see how the assert() macro was
implement, I ran across
#if defined __cplusplus && __GNUC_PREREQ (2,95)
# define __ASSERT_VOID_CAST static_cast<void>
#else
# define __ASSERT_VOID_CAST (void)
#endif
#ifdef NDEBUG
# define assert(expr) (__ASSERT_VOID_CAST (0))
#else /* Not NDEBUG. */
/* some code */
#endif
Is there any could reason making my macro ((void)0) when I disable it?
The macro I've created is
#ifndef NDEBUG
# define ERROR_MESSAGE(s) fprintf(stderr, "%s(): %s\n", __func__, (s));
#else
# define ERROR_MESSAGE(s)
#endif
However, when I checked assert.h to see how the assert() macro was
implement, I ran across
#if defined __cplusplus && __GNUC_PREREQ (2,95)
# define __ASSERT_VOID_CAST static_cast<void>
#else
# define __ASSERT_VOID_CAST (void)
#endif
#ifdef NDEBUG
# define assert(expr) (__ASSERT_VOID_CAST (0))
#else /* Not NDEBUG. */
/* some code */
#endif
Is there any could reason making my macro ((void)0) when I disable it?