Take the 2-minute tour ×  See the struct I used bellow. I wish
to solve this problem in a portable way.  The code I used for
finding the absolute address of the struct was: (char*)data -
sizeof(struct block); (where data is the address to the data in
the struct block). It did not work on this struct.  I made a
test program seen bellow where the last assert fails.  If I
change unsigned int free:1; to unsigned int free; both prints
will print 12 and thus sizeof has given me the expected result.
Thanks in advance.  #include <stdio.h> #include <stdlib.h>
#include <assert.h>  struct block {         size_t
size;         struct block*   next;         unsigned int
free:1;         char            data[];  int main(void)
struct block*   avail;         struct block*   b;          avail
= malloc(sizeof(struct block) + 10);          printf("%zu \n",
sizeof(struct block)); // prints 12          printf("%zu\n",
avail->data - (char*)&avail->size); //prints 9          b =
(struct block*)((char*)avail->dat