在C中应用##运算符 [英] application of ## operator in C
问题描述
大家好
什么是应用程序/示例,需要连接2个
预处理器变量。
ie 申请 ## C / C ++中的运算符
i认为它的唯一用途是在编译器构造中,但我怎么也不知道
知道,
请任何一个帮助我。
再见
sandeep
8月21日,下午6:38,mail2sandee ... @ gmail.com
< mail2sandee ... @ gmail.comwrote:
大家好
什么是应用程序/示例,需要连接2个
预处理器变量。
即应用程序" ## C / C ++中的运算符
i认为它的唯一用途是在编译器构造中,但我怎么也不知道
知道,
请任何一个帮助我。
再见
sandeep
它用于字符串文字中的宏替换。
它也被称为字符串化运算符。
它用于避免警告消息,如
"警告:字符串文字中的宏替换
#define MYPRINTF(var,fmt)\
printf(" MYPRINTF Prints"#var" =" #fmt" \\\
" ;,var)
所以调用如 - MYPRINTF(i,%d);
将扩展为 - printf(" MYPRINTF Prints i =% d \ n,i);
希望这会有所帮助。
最诚挚的问候,
Karthik Balaguru
8月21日上午9:56,karthikbalaguru< karthikbalagur ... @ gmail.com>
写道:
8月21日下午6:38,mail2sandee ... @ gmail.com
< mail2sandee ... @ gmail .comwrote:
hi all
需要连接的应用程序/示例是什么2
预处理器变量。
即应用程序 ## C / C ++中的运算符
i认为它的唯一用途是在编译器构造中,但我怎么也不知道
知道,
请任何一个帮助我。
再见
sandeep
它用于字符串文字中的宏替换。
它也被称为字符串化运算符。
您正在考虑使用#运算符,OP询问用于标记粘贴的##
运算符。 />
Robert Gamble
ma ************ @ gmail.com 写道:
hi all
什么是应用程序/示例,需要串联2个
预处理器变量。
即应用程序 ## C / C ++中的运算符
尝试C FAQ, http://c-faq.com/cpp/index.html 可能与问题10.20以后的
相关。
hi all
what are the applications / examples that requires concatenation of 2
pre-processor variables.
i.e applications of " ## " operators in C/C++
i think its only use is in Compiler construction, but how i don''t
know,
pls any one help me.
bye
sandeep
On Aug 21, 6:38 pm, "mail2sandee...@gmail.com"
<mail2sandee...@gmail.comwrote:hi all
what are the applications / examples that requires concatenation of 2
pre-processor variables.
i.e applications of " ## " operators in C/C++
i think its only use is in Compiler construction, but how i don''t
know,
pls any one help me.
bye
sandeepIt is used for the Macro replacement within a String Literal .
It is also called as stringizing operator .
It is used to avoid the warning message like
"warning : macro replacement within string literal"
#define MYPRINTF(var,fmt) \
printf("MYPRINTF Prints "#var" = "#fmt" \n",var)
so invocations like - MYPRINTF(i,%d);
will be expanded to - printf("MYPRINTF Prints i = %d \n",i);
Hope this helps.
Best Regards,
Karthik Balaguru
On Aug 21, 9:56 am, karthikbalaguru <karthikbalagur...@gmail.com>
wrote:On Aug 21, 6:38 pm, "mail2sandee...@gmail.com"
<mail2sandee...@gmail.comwrote:hi all
what are the applications / examples that requires concatenation of 2
pre-processor variables.
i.e applications of " ## " operators in C/C++
i think its only use is in Compiler construction, but how i don''t
know,
pls any one help me.
bye
sandeep
It is used for the Macro replacement within a String Literal .
It is also called as stringizing operator .You are thinking of the # operator, the OP was asking about the ##
operator which is used for token pasting.
Robert Gamble
ma************@gmail.com wrote:hi all
what are the applications / examples that requires concatenation of 2
pre-processor variables.
i.e applications of " ## " operators in C/C++Try the C FAQ, http://c-faq.com/cpp/index.html is probably relevant
around question 10.20 onwards.
这篇关于在C中应用##运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!