Mercurial > hg > CbC > CbC_gcc
view CbC-examples/test2.c @ 103:edcadcec937d
modify __rectype
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 23 Mar 2012 17:11:33 +0900 |
parents | 365b84b6fe04 |
children |
line wrap: on
line source
#define __environment _CbC_environment #define __return _CbC_return #include <stdio.h> int sender_bit; __code (*ret)(int,void *); void *env; struct packet { int bit; char *msg; __code (*next)(); }; __code print_struct(struct packet pkt) { printf("#0017:bit: %d\n", pkt.bit); printf("#0018:message: %s\n", pkt.msg); goto ret(0, env); } __code initSender(int init_bit, struct packet pkt) { sender_bit = init_bit; pkt.next = print_struct; printf("#0026:initSender bit: %d\n", pkt.bit); printf("#0027:initSender message: %s\n", pkt.msg); printf("#0028:sender_bit: %d\n", sender_bit); goto print_struct(pkt); } int main(void) { struct packet pkt; pkt.bit = 1; pkt.msg = "hogehoge"; pkt.next = initSender; ret = __return; env = __environment; printf("#0040:main bit: %d\n", pkt.bit); printf("#0041:main message: %s\n", pkt.msg); goto initSender(0, pkt); }