Simple answers, see examples.
I machine 64 bits, pointer 8 bytes; 32 bits, pointer 4 bytes.
Files: SIZEOF.C
#include <stdio.h>typedef struct SS{ char name[131]; short type; int size; int offset; unsigned short Precision; void *data; #if 0}__attribute__ (( __packed__) AA; #else}colattr_t; #endifint main (INT&NBSP;ARGC,&NBSP;CHAR&NBSP;**ARGV) { printf ("%d \n", sIzeof (AA)); return 0;}
Seemingly 151 bytes (#if 1 can be seen, attribute compact byte network), the actual 160 bytes.
Answer: is 8-byte aligned, because void * is 8 bytes, minus void * Maximum is 4 bytes, which is aligned by 4 bytes .
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/71/41/wKioL1XJ2biSLEeWAABBh1IyLyA483.jpg "title=" Boke.jpg "alt=" Wkiol1xj2bisleewaabbh1iylya483.jpg "/>
Analysis: All are aligned to 8 bytes.
The first line, Char cname[128] bytes.
The second line, with 3 bytes and a short type, is 8 bytes in combination. (A total of 5 bytes, more than 3 of the int type).
In the third row, the int size and int offset combinations account for 8 bytes.
Row four, void * Because 64 bits account for 8 bytes.
This article is from the "Self-summary" blog, please be sure to keep this source http://2714254.blog.51cto.com/2704254/1683780
On the algorithm of the structure byte of C + +