Q:

multiple definition of a function

I defined a function to show a message when debug flags are off in a header file as below:
#ifdef  NDEBUG

#define debug_msg(expr, msg)        (static_cast<void>(0))

#else /* Not NDEBUG.  */

#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 in more than a file, I get the following error:

multiple definition of `_show_in_debug(char const*, unsigned int, char
  const*, char const*)'

I don't exactly know what I am doing wrong here, any help ?

A:

If you include that header into more than one .c file, each of them will define the function. That is what the error says.
What you should do is to only declare the function in the header (i.e. only put the prototype there; which you always should) and then define it in a single .c file (i.e. put the body in the .c file), encapsulated into the same switches as the prototype.
Header to be changed to this:
/* ... as you quoted ... */
    void _show_in_debug(const char *_file, unsigned int _line,
        const char *_function, const char *_msg);
/* ... rest of what you quoted ... */

Code file to contain this:
#incude <stdio.h>
#include "Yourheader.h"

#ifdef  NDEBUG
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

A:

Even with the include guards, you end up with a definition of _show_in_debug in each compilation unit.  Linking those units then results to a multiple definition error.
For a debugging function like this, define the function as static so that it is not visible outside its compilation unit:
static 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);
}

