#define中的问题 [英] problem in #define

查看:118
本文介绍了#define中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#define A3FID(T)A3FCHUNCK_ID _ ## T
#定义A3FNAME(T)A3FCHUNK_NAME _ ## T
#define A3F_ID_NAME(T)((const unsigned long)A3FID(T)),A3FNAME(T)


请解释上面的代码?是宏吗?可能是T?它显示未定义..但不给出任何错误...

#define A3FID(T) A3FCHUNCK_ID_##T
#define A3FNAME(T) A3FCHUNK_NAME_##T
#define A3F_ID_NAME(T) ((const unsigned long)A3FID(T)),A3FNAME(T)


Please explain above Code? IS is Macro? What may be T? It shows undefined.. but does not give any Error...

推荐答案

是的,它们是使用串联的宏. "T"是您传递给宏的参数.

例如这样的语句:"int a = A3FID(PARAM);"将(在预处理之后)转换为"int a = A3FCHUNCK_ID_PARAM;"

希望对您有所帮助.
Yes, they are macros that uses concatenation. The ''T'' is the parameter that you pass to the macro.

e.g. a statement like "int a = A3FID(PARAM);" will translate(after preprocessing) into "int a = A3FCHUNCK_ID_PARAM;"

hope that helps.


每个#define语句都会创建一个宏.前两个前缀带有标签的值,而第三个生成一些语句,例如:
Each #define statement creates a macro. The first two prefix some value with a label, and the third generates some statement for example:
A3F_ID_NAME(22)

// generates
((const unsigned long)A3FCHUNCK_ID22, A3FCHUNCK_NAME22


但是,我不知道在没有更多源代码的情况下应该生成什么代码. ##运算符是令牌粘贴程序 [


However, I have no idea what code this is supposed to generate without seeing more of your source. The ## operator is the token paster[^], used by the preprocessor.


这篇关于#define中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆