- 论坛徽章:
- 0
|
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返回值信息,每个类型的打印函数可通过查表获得.
这个宏该如何实现呢? |
|