view 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
line wrap: on
line source

#include<stdio.h>
#include<math.h>

#define dprint(f, args...) \
	printf("in %s env=%p: "f, __FUNCTION__, __builtin_frame_address(1), ## args)

typedef struct {
	int a;
	double b;
	char *c;
} STRUCT;

int
test(int a)
{
	return (int)pow(a, 2.0);
}


int
callee(int a, STRUCT s, int b)
	/*  |-|----|-|  */
{
	dprint("a=%d,b=%d\n", a,b);
	dprint("s.a=%d,s.b=%lf,s.c=%s\n", s.a, s.b, s.c);
	return a+b+ s.a;
}

int
caller(STRUCT s, int a, double b)
	/*  |----|-|--|  */
{
	STRUCT s0;// = {44, 55.5, "aiueo2"};
	//int a0 = 55;
	//a0 = a;
	s0 = s;

	return callee(10, s0, 20);
}

int
main (int argc, char **argv)
{
	int r;
	STRUCT s = { 33, 44.4, "aiueo" };

	r = caller(s, 11, 22.2);
	//r = caller(11,22,33,44, 55,66,77,88);
	printf("r = %d\n", r);
}