Mercurial > hg > CbC > CbC_gcc
comparison CbC-examples/parallel_check/c-struct.c @ 42:9e4f9e20b8f1
add some examples.
author | kent@teto.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Mon, 25 Jan 2010 17:13:59 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
41:c816ae4380d7 | 42:9e4f9e20b8f1 |
---|---|
1 #include<stdio.h> | |
2 #include<math.h> | |
3 | |
4 #define dprint(f, args...) \ | |
5 printf("in %s env=%p: "f, __FUNCTION__, __builtin_frame_address(1), ## args) | |
6 | |
7 typedef struct { | |
8 int a; | |
9 double b; | |
10 char *c; | |
11 } STRUCT; | |
12 | |
13 int | |
14 test(int a) | |
15 { | |
16 return (int)pow(a, 2.0); | |
17 } | |
18 | |
19 | |
20 int | |
21 callee(int a, STRUCT s, int b) | |
22 /* |-|----|-| */ | |
23 { | |
24 dprint("a=%d,b=%d\n", a,b); | |
25 dprint("s.a=%d,s.b=%lf,s.c=%s\n", s.a, s.b, s.c); | |
26 return a+b+ s.a; | |
27 } | |
28 | |
29 int | |
30 caller(STRUCT s, int a, double b) | |
31 /* |----|-|--| */ | |
32 { | |
33 STRUCT s0;// = {44, 55.5, "aiueo2"}; | |
34 //int a0 = 55; | |
35 //a0 = a; | |
36 s0 = s; | |
37 | |
38 return callee(10, s0, 20); | |
39 } | |
40 | |
41 int | |
42 main (int argc, char **argv) | |
43 { | |
44 int r; | |
45 STRUCT s = { 33, 44.4, "aiueo" }; | |
46 | |
47 r = caller(s, 11, 22.2); | |
48 //r = caller(11,22,33,44, 55,66,77,88); | |
49 printf("r = %d\n", r); | |
50 } | |
51 |