Sorry for possible duplicates. Because I couldn't find the answer
So my question is. I am trying to get an address to the function
void func() {}
void* funcPtr = func;
I am using C++ 17 at Visual Studio and clang giving me that warning
implicit conversion between pointer-to-function and pointer-to-object is a microsoft extension[clang-diagnostic-microsoft-cast]
I want to use it, to check if two pointer to a function are actually pointing to the same function. For example:
const std::function<void()>& stdFunc1 = func;
const std::function<void()>& stdFunc2 = func;
void* funcAdr1 = *stdFunc1.target<void(*)()>();
void* funcAdr2 = *stdFunc2.target<void(*)()>();
bool test = funcAdr1 == funcAdr2;
What clang trying me to tell. And what possible workaround can I do? For my project it is not really necessary. But I want to know it for future.