...../PluginLoader.h:34: multiple definition of 'Dummy_Func_For_Generating_FUNCTION_NAME_Macro()'
The above error is output for the below code. I have include guards in my file. And everything else compiles fine.
EDIT: What I was trying to achieve was to check if __PRETTY_FUNCTION__
was defined, and if it was, use it later in code via FUNCTION_NAME
macro (For logging purposes). If __PRETTY_FUNCTION__
is not defined, use next best thing and so on. However, the responses I got made me realize that this impossible. So, if __PRETTY_FUNCTION__
and all these others are not macros, what are they? And how do I check if a certain implementation has one of them or not?
void Dummy_Func_For_Generating_FUNCTION_NAME_Macro()
{
#ifndef FUNCTION_NAME
#ifdef __PRETTY_FUNCTION__
#define FUNCTION_NAME __PRETTY_FUNCTION__
#elif __FUNCTION__
#define FUNCTION_NAME __FUNCTION__
#elif __func__
#define FUNCTION_NAME __func__
#else
#define FUNCTION_NAME ""
#endif
#endif
}