##替换特定字符串,用法详见define.c
#define.c文件:
#include
#define FUNC_STOP stop
int player_stop()
{
return 0;
}
int player_start()
{
return 2;
}
int player_resume()
{
return 3;
}
int player_play_1x()
{
return 4;
}
typedef struct
{
int (*stop)();
int (*start)();
int (*resume)();
int (*play_1x)();
}PLAYER;
int main()
{
PLAYER player;
#define SET(x) \
printf("set %s\n", #x); \
player.x = player_##x
#define SSET(x) \
SET(x)
//SET(stop);
/*注意下面这行语句*/
SSET(FUNC_STOP);
SET(start);
SET(resume);
SET(play_1x);
printf("%d %d %d %d\n", player.stop(), player.start(), player.resume(), player.play_1x());
return 0;
}
阅读(1172) | 评论(0) | 转发(0) |