2 !!DESCRIPTION!! return values, implicit type conversion on return
3 !!ORIGIN!! cc65 devel list
4 !!LICENCE!! Public Domain
10 unsigned char val_char=0x76;
11 unsigned int val_int=0x5678;
12 unsigned long val_long=0x12345678;
14 int test1_int_char(void)
18 int test1_int_int(void)
23 int test2_int_char(void)
27 int test2_int_int(void)
32 long test1_long_char(void)
36 long test1_long_int(void)
40 long test1_long_long(void)
45 long test2_long_char(void)
47 return (long)val_char;
49 long test2_long_int(void)
53 long test2_long_long(void)
55 return (long)val_long;
58 #define dotest(_n,_a,_v) \
60 printf("%04lx %04lx,",(unsigned long)_n,(unsigned long)_v); \
61 if(_n!=_v) printf("failed\n"); \
69 printf("\nwithout cast:\n");
71 printf("return int\n");
73 dotest(i,test1_int_char(),0x76);
74 dotest(i,test1_int_int(),0x5678);
76 printf("return long\n");
78 dotest(l,test1_long_char(),0x76);
79 dotest(l,test1_long_int(),0x5678);
80 dotest(l,test1_long_long(),0x12345678);
82 printf("\nwith cast:\n");
84 printf("return int\n");
86 dotest(i,test2_int_char(),0x76);
87 dotest(i,test2_int_int(),0x5678);
89 printf("return long\n");
91 dotest(l,test2_long_char(),0x76);
92 dotest(l,test2_long_int(),0x5678);
93 dotest(l,test2_long_long(),0x12345678);