There is no guarantee of any connection between the sizes of these two types, nor that they can be accurately represented in the other using round-trip spells. All of this is determined by implementation.
With that being said, in the real world, if you are not dealing with really obscurely obsolete 16-bit systems or odd DSPs or such, sizeof(int) will be less than or equal to sizeof(void *) , and you can faithfully convert int values โโto void * to pass them to interfaces (e.g. pthread_create ) that take the general argument void * to avoid wasting and allocating memory to hold one int . In particular, if you are already using POSIX or Windows interfaces, this is certainly a safe, real guess.
You should never assume that void * can be accurately represented in int (i.e. hovering over int and back). This does not work on any popular 64-bit real-world systems, and the percentage of systems on which it works will probably fall in the near future.
source share