c - Why is casting from int to void * allowed? -


why casting void* int , vice versa allowed in c? used other pthread?

it allowed, behavior implementation-defined.

sometimes, under situation (on particular platform/ architecture), provision may useful quick-and-dirty hacks/tricks involving memory addresses using operators needs int operands. [ex: xor operation]. can useful memory optimization limited-memory embedded devices.

to quote standard regarding functionality,

the mapping functions converting pointer integer or integer pointer intended consistent addressing structure of execution environment.

related reading: c11, chapter 6.3.2.3,

paragraph 5:

an integer may converted pointer type. except specified, result implementation-defined, might not correctly aligned, might not point entity of referenced type, , might trap representation.

and paragraph 6:

any pointer type may converted integer type. except specified, result implementation-defined. if result cannot represented in integer type, behavior undefined. result need not in range of values of integer type.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -