GCC #define for alignment

Duane Ellis duane@duaneellis.com
Wed Dec 3 11:34:00 GMT 2008


Hello,

I have a problem in a memory allocator that acts like Malloc(),  where I 
need to align the result value in the same form as malloc.

I can easily hard code something :-( but I'd rather use some "well 
known" perhaps ANSI-C  #define for the alignment value.
It could be a GCC specific #define :-( but I'd rather it not be.

Simply put, for portability reasons I'd rather not have a hard coded 
thing like this:

    // ensure proper machine alignment
    x = (x + 3) & (~3);

Suggestions? Sure I could use sizeof(void *) also..

-Duane.




More information about the Gcc-help mailing list