I defined a function to display a message when debug flags are disabled in the header file, as shown below:
#ifdef NDEBUG
#define debug_msg(expr, msg) (static_cast<void>(0))
#else
#ifndef SHOW_DEBUG_H_
#define SHOW_DEBUG_H_
#include <stdio.h>
void _show_in_debug(const char *_file, unsigned int _line,
const char *_function, const char *_msg)
{
printf("%s\t%d\t%s\t%s\n", _file, _line, _function, _msg);
fflush(NULL);
}
#endif
#define debug_msg(expr, msg) \
((expr) \
? _show_in_debug(__FILE__, __LINE__, __func__, msg) \
: static_cast<void>(0))
#endif
when I include the header more than in the file, I get the following error:
several definitions of `_show_in_debug (char const *, unsigned int, charconst *, char const *) '
I don’t know exactly what I'm doing wrong here, any help?
source
share