二进制数计算出问题
1、在64位机上编译程序碰到这样一个错误
../../ipa_link/libiberty/objalloc.c: In function `objalloc_create':
../../ipa_link/libiberty/objalloc.c:106: warning: implicit declaration of function `__builtin_offsetof'
../../ipa_link/libiberty/objalloc.c:106: error: syntax error before "struct"
make[3]: *** [objalloc.o] Error 1
2、源代码:
105 ret->current_ptr =(char *) chunk
106 + CHUNK_HEADER_SIZE;
3、其中出错的原因是CHUNK_HEADER_SIZE,定义如下:
#define CHUNK_HEADER_SIZE \
((sizeof (struct objalloc_chunk) + OBJALLOC_ALIGN - 1) \
&~ (OBJALLOC_ALIGN - 1))
4、
感觉是只要(OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1)就会有问题
ret->current_ptr 为char *
chunk 为 stuct objalloc_chunk *