I try to use WPP under user mode, managed to successfully use it in VS10, Release target by adding to the proj file:
<PropertyGroup><WdkDir>c:\work\Proj\wppTest\DDK\</WdkDir><MyTargetsDir>c:\work\Proj\wppTest</MyTargetsDir> </PropertyGroup>
...
<ImportGroup Label="ExtensionTargets">
<Import Project="$(MyTargetsDir)\Wpp.targets" />
</ImportGroup>
Then Wpp.targets is defined like this:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ExtensionsToDeleteOnClean>$(ExtensionsToDeleteOnClean);*.tmh</ExtensionsToDeleteOnClean>
</PropertyGroup>
<ItemGroup>
<CoreCppClean Include="@(CoreCppClean);$(ProjectDir)">
<FilePatternsToDelete>*.tmh</FilePatternsToDelete>
</CoreCppClean>
</ItemGroup>
<ItemGroup>
<TraceWppSources Include="@(ClCompile)" Exclude="stdafx.cpp" />
</ItemGroup>
<Target Name="TraceWpp" BeforeTargets="ClCompile" Inputs="@(TraceWppSources)" Outputs="@(TraceWppSources -> '%(Filename).tmh')">
<Exec Command="cd $(ProjectDir)" />
<Message Importance="high" Text="Creating tmh"/>
<Exec Command="$(WdkDir)\bin\x86\tracewpp.EXE -cfgdir:$(WdkDir)\bin\wppconfig\rev1 -odir:. @(TraceWppSources, ' ')" />
<Message Importance="high" Text="tmh created"/>
</Target>
</Project>
This steps were taken from article: http://www.devproconnections.com/article/visual-studio-2010/wpp-tracing-in-visual-c-2010-projects
When trying to compile this under VS10->Debug I can see that "tmh" files are being generated only that I get error when actualy I want to log something:
DoTraceMessage(TRACE_ERROR, L"Aha"); // error C2065: 'TRACE_ERROR' : undeclared identifier error C3861: 'WPP_CALL_Application_Test_cpp': identifier not found
As I've said I have no issues with the same code on VS10->Release target. Here is my defines for reference:
#pragma once
#define WPP_CONTROL_GUIDS \
WPP_DEFINE_CONTROL_GUID(CtlGuid,(28EE579B, CF67, 43b6, 9D19, 8930E7AAA131), \
\
WPP_DEFINE_BIT(TRACE_ERROR) \
WPP_DEFINE_BIT(TRACE_WARNING) \
WPP_DEFINE_BIT(TRACE_INFO1) \
WPP_DEFINE_BIT(TRACE_INFO2) \
)
Does anyone have any idea why that might work using Release mode but does not work under Debug mode ?
Yes, the issue is that when you compile with the "Debug symbols in PDB with Edit & Continue support" the compiler does not resolve the __LINE__ macro.
The WPP compiler defines a function WPP_CALL_Application_Test_cpp51 if you trace from Application_Test.cpp line 51, and uses __FILE__ and __LINE__ to do so.