リスト10 リスト11


〔リスト10〕型あるいはアラインメントを問い合わせたソース(test91.c)
#include <stdio.h>
//型あるいは変数のアラインメントを問い合わせる
	
int main(void)
{
    double  a;
    float   b;
    long long   c;
    int d;
    char    e;
    struct foo { 
        int d;
        char    e;
    } foo1;
    printf("doubleの境界----%d\n",__alignof__(a));
    printf("floatの境界----%d\n",__alignof__(b));
    printf("long longの境界----%d\n",__alignof__(c));
    printf("intの境界----%d\n",__alignof__(d));
    printf("charの境界----%d\n",__alignof__(e));
    printf("fooの境界----%d\n",__alignof__(foo1));
    printf("foo.eの境界----%d\n",__alignof__(foo1.e));
    return 0;
}


〔リスト11〕型あるいはアラインメントを問い合わせたソースから生成されたアセンブラ(test91.s)
    .file       "test91.c"
    .version    "01.01"
gcc2_compiled.:
.section    .rodata
.LC0:
    .string "double\244\316\266\255\263\246----%d\n"
.LC1:
    .string "float\244\316\266\255\263\246----%d\n"
.LC2:
    .string "long long\244\316\266\255\263\246----%d\n"
.LC3:
    .string "int\244\316\266\255\263\246----%d\n"
.LC4:
    .string "char\244\316\266\255\263\246----%d\n"
.LC5:
    .string "foo\244\316\266\255\263\246----%d\n"
.LC6:
    .string "foo.e\244\316\266\255\263\246----%d\n"
.text
    .align  4
.globl  main
    .type   main,@function
main:
    pushl   %ebp
    movl    %esp,%ebp
    subl    $8,%esp
    addl    $-8,%esp
    pushl   $4
    pushl   $.LC0
    call    printf
    addl    $-8,%esp
    pushl   $4
    pushl   $.LC1
    call    printf
    addl    $32,%esp
    addl    $-8,%esp
    pushl   $4
    pushl   $.LC2
    call    printf
    addl    $-8,%esp
    pushl   $.LC3
    call    printf
    addl    $32,%esp
    addl    $-8,%esp
    pushl   $1
    pushl   $.LC4
    call    printf
    addl    $-8,%esp
    pushl   $4
    pushl   $.LC5
    call    printf
    addl    $32,%esp
    addl    $-8,%esp
    pushl   $1
    pushl   $.LC6
    pushl   $4
    call    printf
    xorl    %eax,%eax
    movl    %ebp,%esp
    popl    %ebp
    ret
.Lfe1:
    .size   main,.Lfe1-main
    .ident  "GCC: (GNU) 2.95.3 20010315 (release)"