Dave's Brain

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; ... }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.