[Qt-interest] Portable way to get compiler's memory alignment

Nikos Chantziaras realnc at arcor.de
Thu Mar 25 06:27:53 CET 2010


Is there some portable method, trick, hack, etc, to get the compiler's 
memory alignment?  I'm currently simply assuming 4 byte alignment, which 
seems to work for 32-bit as well as 64-bit GCC.  Aligning a size to 
4-byte worst-case is currently done with:

   (size + 3) & ~3

but I suspect this will be wrong on some systems.  Can Qt be of 
assistance here?  If not, what do you guys recommend?



More information about the Qt-interest-old mailing list