I read about pthreads here . In one example, they provided this source code.
When creating a stream, they pass a long type whose type is used as the void * type for the function !.
Inside the function, they get this value and the inverse to get a long value.
Q1: Is it allowed to convert a pointer type to a primitive data type and vice versa (In C and C ++)?
Q2. If so, is it good to do this? Shouldn't they create a pointer to this long type, and then type this pointer as void * and pass it to the function.
Is this idea of converting a primitive type to a pointer type very confusing? Converting from any pointer type to void * in an understandable, but how primitive data type is stored in void * type? Is it not possible that a particular system size of a primitive type may be larger than the size allocated for the pointer type?
source share