This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I'm using TI clang v2.1.2.LTS
I have a class CbADC_Device with a member function public: uint32 OpenSetCb(uint32_t){}
I'm trying to create a pointer to that funciton
#include <cstdint>
using FunctionPtrType = int32_t (CbADC_Device::*)(uint32_t);
FunctionPtrType funcPtr = &CbADC_Device::OpenSetCb;
void* ptr = (void*)(funcPtr); <==================================== ERROR
getting clang error
error: cannot initialize a variable of type 'void *' with an lvalue of type 'FunctionPtrType' (aka 'int32_t (CbADC_Device::*)(uint32_t)')
tried with reinterpret cast - also error
How can I get a void * ptr to the function ?
Please advice
Thanks,
Eli
A pointer to a member function is one of the trickier parts of C++. Please see this FAQ (not from TI).
Thanks and regards,
-George
Hi George,
I understand the article.
I see that the current design breaks C++, but I have a large project compiled with GCC that I'm trying to compile with CLANG to work with TI SDK examples .
At this point I cannot redesign the whole "call back mechanism".
I'm looking for an equivalent solution like in GCC #pragma GCC diagnostic ignored
-Wpmf-conversions[Warn when converting the type of pointers to member functions]
I'm using clang v2.1.2LTS is there a more recent version supporting this particular pragma ?
Is there any other way besides redesigning the project ?
Thanks,
Eli
The central problem is that tiarmclang (and I think this applies to all clang compilers) categorizes as an error any attempt to change a pointer-to-member-function to a void pointer, or vice versa. No error can be changed into a warning. And only a warning, not an error, can be ignored. Unfortunately, I cannot find any way around this central problem.
Thanks and regards,
-George