Is there a way to align a pointer in C? Suppose I\'m writing data to an array stack (so the pointer goes downward) and I want the next data I write to be 4-aligned so the da
For some reason I can't use modulo or bitwise operations. In this case:
void *alignAddress = (void*)((((intptr_t)address + align - 1) / align) * align) ;
For C++:
template
constexpr T padding(T value)
{
return ((value + align - 1) / align) * align;
}
...
char* alignAddress = reinterpret_cast(padding<8>(reinterpret_cast(address)))