开发者

No support for multi-line MACROs during WPP tracing

I'm adding tracing to a user-mode application based on "Event Tracing for Windows" (ETW) using WPP (a pre-processor) and visual studio compiler.

This MSDN content explains how convert existing macros to allow t开发者_Go百科racing from within them. The example there is CHECK_HR, which gets a single argument (HR) and generates a trace if it is not 0.

Now, I found that the generated pre-processor function don't work if the argument is multi-line, due to the way WPP works. But I could not find any reference to such a problem!

CHECK_HR(DoSomething(a,b,c)); // works   
CHECK_HR(DoSomething(a,  
    b, c)); // don't work

Problem is that when the macro is encountered by the pre-processor in line 17 of File.cpp wpp it generates a function called something like wpp_File_cpp17 and uses LINE to call it from the macro. But for multi-line macro as above the __ LINE__ will be 18 and one will get an error:

wpp_File_cpp18: unknown function

Does anyone have a work-around for this issue? I know MSFT use WPP extensively internally, I wonder how they handle this...


I tried to reproduce this issue, without success -- multi-line WPP calls work for me, so the error you're getting seems kind of weird. Did you modify the CHECK_HR macro in any way?

You could try putting slashes at the end of each line of the call:

CHECK_HR(DoSomething(a, \
                     b, \
                     c));

Also, in your example you're missing a closing parenthesis, this causes WPP_CALL_blahblah_undefined. But most likely that's just a typo in this example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜