view test/tmp11.c @ 896:d712ee10feb7

local_nptr for locally defined struct
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 06 Apr 2014 19:20:58 +0900
parents bc919d849346
children
line wrap: on
line source

int printf(const char *format, ...);

typedef struct nametable {
        char *nm;
        int sc,ty,dsp; } NMTBL;
NMTBL *a;
NMTBL f;

NMTBL *
test2(char *n) {
    printf("#0010:s %s\n",n);
    return a;
}

int
test0(int a,int b,int c) {
    printf("#0016:a %d b %d c %d\n",a,b,c);
    return 0;
}

int
test1(a,b,c) 
int a,b;int c;
{
    return test0(a,b,c);
}

int heap[10];

#define ncaddr(e)   (*(NMTBL**)&heap[e+2])

int
main()
{
    int d;
    NMTBL *b;
    f.nm = "_name";
    a = &f;
    b = test2("test");
    d = test1(1,2,3);
    printf("#0040:return %d\n",d);

    NMTBL **p = (NMTBL**)&heap[2];
    *p = &f;
    b = &f;
    int e = 0;
    printf("#0046:f.nm          %s\n",f.nm);
    printf("#0047:b->nm         %s\n",b->nm);
    printf("#0048:(*p)->nm      %s\n",(*p)->nm);
    printf("#0049:ncaddr(e)->nm %s\n",ncaddr(e)->nm);

    return d;
}

/* end */