Mercurial > hg > CbC > old > device
view test/call.c @ 689:baa67e2e54d2
*** empty log message ***
author | kono |
---|---|
date | Sun, 07 Oct 2007 17:46:00 +0900 |
parents | 10c8eaf0f73b |
children | c2c709727221 |
line wrap: on
line source
#ifndef INLINE #define INLINE #endif int printf(const char *format, ...); INLINE int a0(int i); int (*conv)(int); INLINE int a0(int i) { return i+3; } INLINE int a1(int i) { return i-3; } INLINE int a2(int i,int conv(int)) { return conv(i); } INLINE int a3(int i,int (*conv)(int)) { return conv(i); } INLINE int a4(int i,int conv(int)) { return (*conv)(i); } INLINE static int a5(int i,int (*conv)(int)) { return (*conv)(i); } typedef int (*fptr)(int,int (*)(int)); unsigned long addrs[]={ (unsigned long)&a0, (unsigned long)&a5, (unsigned long)a0, (unsigned long)a5, 0, }; fptr faddrs[]={ &a2, &a5, a2, a5, 0, }; INLINE void print( int i, void (*print)(int i,void (*)()) ); INLINE void print0( int i, void (*print1)(int i,void (*)()) ) { printf("print0 %d %d\n",print1 == print,i); } INLINE void print( int i, void (*print)(int i,void (*)()) ) { print0(i,print); (*print)(i,print); } INLINE void pppp( void (*pppp)(void (*)()) ); INLINE void pppp0( void (*pppp1)(void (*)()) ) { printf("pppp0 %d\n",pppp1 == pppp); } INLINE void pppp( void (*pppp)(void (*)()) ) { pppp0(pppp); (*pppp)(pppp); } int main(int ac,char *av[]) { int j,k; conv = a0; j = conv(3); k = a2(4,a1); printf("#0070:6 1 = %d %d\n",j,k); k = a3(4,a1); printf("#0072:6 1 = %d %d\n",j,k); k = a4(4,a1); printf("#0074:6 1 = %d %d\n",j,k); k = a5(4,a1); printf("#0076: 1 = %d %d\n",j,k); printf("#0077: 1 = %d\n",(unsigned long)a0 == addrs[0]); printf("#0078: 1 = %d\n",(unsigned long)a5 == addrs[1]); printf("#0079: 1 = %d\n",(unsigned long)a0 == addrs[2]); printf("#0080: 1 = %d\n",(unsigned long)a5 == addrs[3]); printf("#0082: 1 = %d\n",a2 == faddrs[0]); printf("#0083: 1 = %d\n",a5 == faddrs[1]); printf("#0084: 1 = %d\n",&a2 == faddrs[2]); printf("#0085: 1 = %d\n",&a5 == faddrs[3]); print(55,print0); pppp(pppp0); return 0; }