免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1317 | 回复: 1
打印 上一主题 下一主题

关于调试程序的宏问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-09-01 16:58 |只看该作者 |倒序浏览
struct student{
        struct man man;
        char *id;
        char *major;
        struct teacher *teacher;
};

struct teacher{
        struct man man;
        char *major;
        char *addr;
        struct student *student;
};

struct man{
        int age;
        char *name;
};

void show_student(struct student *student)
{
        show_man(&student->man);
        _show_student(student);
}

void show_teacher(struct teacher *teacher)
{
        show_teacher(&teacher->man);
        _show_teacher(teacher);
}

void show_man(struct man *man)
{
        _show_man(man);
}

char* funcion(struct student *student,struct teacher *teacher)
{
        student->teacher=teacher;
        teacher->student=student;
        return student->major;
}

DECLARE_FUNCTION_TABLE(table)
        FUNCTION_ADD(struct student,show_student);
        FUNCTION_ADD(struct teacher,show_teacher);
        FUNCTION_ADD(struct man    ,show_man        );
END_DECLARE_TABLE

#define debug(func,...) _debug(__FILE__,__FUNCTION__,__LINE__,#func)

int main()
{
        struct student *student=...;//定义一个学生并设置信息
        struct teacher *teacher=...;//定义一个老师并设置信息
//        char *major=function(student,teacher);
        char *major=debug(function,student,teacher);
}

每定义一个类型或函数都将其加入表中.
debug宏通过函数名查表得到函数返回值类型,各参数类型及函数指针,
然后将调用该函数,并打印出实参信息和func返回值信息,每个类型的打印函数可通过查表获得.
这个宏该如何实现呢?

论坛徽章:
0
2 [报告]
发表于 2009-09-01 23:52 |只看该作者
函数的返回值如何打印呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP