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".
|
|