小编Zez*_*bye的帖子

C:连续的宏不起作用

我有一个在屏幕上显示字符串的功能.原型是dispStrFont(char* str, struct Font font, int x, int y, int color).

但是因为输入字体很烦人,所以我制作了一个宏#define dispStr(str, x, y, color) dispStrFont(str, normal_font, x, y, color).编译时似乎工作正常(没有错误).

我的大多数字符串都是黑色的,所以我不需要输入颜色.所以我用另一个宏(放在上面的宏之前)使颜色可选:#define dispStr(str, x, y) dispStr(str, x, y, 0).

这两个宏的组合给出了错误,我不知道为什么.

头文件:

#define dispStr(str, x, y) dispStr(str, x, y, 0)
#define dispStr(str, x, y, color) dispStrFont(str, normal_font, x, y, color)
//the define above gives me a warning: "Incompatible redefinition of macro "dispStr" (declared at line 1)"
Run Code Online (Sandbox Code Playgroud)

主文件:

dispStr("test", x, y) //gives me an error, saying …
Run Code Online (Sandbox Code Playgroud)

c macros

1
推荐指数
1
解决办法
137
查看次数

标签 统计

c ×1

macros ×1