Browse - Programming Tips - How do I cast a void * into an enum. Such as at the start of a thread?

Date: 2015jun18
Language: C/C++

Q.  How do I cast a void * into an enum.   Such as at the start of a thread?

A.  Cast to intptr_t first, like this:


void threadMain(void *in) { MyEnum myenum = (MyEnum) (intptr_t) in; ... }