I'm surprised noone's voted up Shao's answer that, as I understand it, it is impossible to do what's asked in standard C99, since converting a pointer to an integral type formally is undefined behavior. (Apart from the standard allowing conversion of uintptr_t
<-> void*
, but the standard does not seem to allow doing any manipulations of the uintptr_t
value and then converting it back.)
↧
Answer by Lutorm for How to allocate aligned memory only using the standard library?
↧