由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - What syntax is this?(about macro)
相关主题
师傅们,C++概念题,弟子有礼了问个函数指针指向操作符的问题
三个C syntax 弱问题metaprogramming
Question on using ## in #define最近在用clj干活。顺便看了看macro 倒吸一口冷气。
如何用 preprocessor unroll for loop?operator overloading (C++)
这个结果是啥,为什么呢?c++ define 一问
Visual studio: 2008: create a macro in compiler configurationask a Javascript question
问低级问题C pre-compiling 如何用macro替换括号?
one question about operator delete请教如何在Powerpoint中使用Macros改变文字颜色
相关话题的讨论汇总
话题: input话题: trace话题: wm话题: what话题: macro
进入Programming版参与讨论
1 (共1页)
M**8
发帖数: 25
1
Given #define TRACE_ID(iD) case iD: return L#iD;
Should
TRACE_ID(WM_INPUT) = WM_INPUT
or
TRACE_ID(WM_INPUT) = LWM_INPUT /* L at the begining */
what does "L" do here?
Thank you,
r*********r
发帖数: 3195
2
the macro should be L##iD.
## is a "token pasting operator".
M**8
发帖数: 25
3
HI,
In one of MS's samples, it uses one #. Actually this is documented in
Visual Studio help document.
Ok, even ## is right, why do we need "L" in the front? I have seen
L"string" for unicode. Have not seen L##X though.
K*****n
发帖数: 65
4
#define TRACE_ID(iD) case iD: return L#iD;
TRACE_ID(WM_INPUT) gives your L"WM_INPUT"
# is called stringizing operator for preprocessor here
As for L macro:
In C, to make a string of wide characters, you need to prefix the string
with the letter "L".
K*****n
发帖数: 65
5

Apparently, instead of getting an iD number, by which you have to look up
its meaning, you gets a meaningful string.
This is a very useful trick to getting meaning out of a #define number.

【在 K*****n 的大作中提到】
: #define TRACE_ID(iD) case iD: return L#iD;
: TRACE_ID(WM_INPUT) gives your L"WM_INPUT"
: # is called stringizing operator for preprocessor here
: As for L macro:
: In C, to make a string of wide characters, you need to prefix the string
: with the letter "L".

1 (共1页)
进入Programming版参与讨论
相关主题
请教如何在Powerpoint中使用Macros改变文字颜色这个结果是啥,为什么呢?
问个overloading new operator的问题Visual studio: 2008: create a macro in compiler configuration
c++ iterator 弱问问低级问题
i +++ jone question about operator delete
师傅们,C++概念题,弟子有礼了问个函数指针指向操作符的问题
三个C syntax 弱问题metaprogramming
Question on using ## in #define最近在用clj干活。顺便看了看macro 倒吸一口冷气。
如何用 preprocessor unroll for loop?operator overloading (C++)
相关话题的讨论汇总
话题: input话题: trace话题: wm话题: what话题: macro