Symptoms
When developing Windows drivers, ReSharper fails to resolve WPP Tracing macros and related symbols (for example, TRACE_CLIENT_SERVER).
Cause
WPP tracing macros are generated during build time. By default, the build toolchain generates .tmh files that generate definitions for WPP macros with __INTELLISENSE__ macro.
Resolution
Depending on the structure of the project and personal preference, one can use the following approaches to resolve this issue:
-
Define the
__INTELLISENSE__macro for ReSharper:- (option 1) Using Visual Studio and ReSharper: define the macro via Additional preprocessor directives in Project Properties under ReSharper
- (option 2) Using
.vcxproj.DotSettingssettings file: add the following configuration string to the DotSettings file:
<s:String x:Key="/Default/CppProjectProperties/AdditionalPreprocessorDefinitions/@EntryValue">__INTELLISENSE__=1</s:String></wpf:ResourceDictionary> - (option 1) Using Visual Studio and ReSharper: define the macro via Additional preprocessor directives in Project Properties under ReSharper
-
Manually add macro definitions copied from the generated
.tmhfiles, replacing__INTELLISENSE__with__RESHARPER__for example:#undef DoDebugTrace #ifdef __RESHARPER__ #define DoDebugTrace(TRACELEVEL, MSG, ...) ((void)(MSG, ## __VA_ARGS__)) -
Change the templates used to generate trace macros. Templates used during build time are defined in
.vcxprojunder<WppGenerateUsingTemplateFile>. One can use an existing template%programfiles(x86)%\Windows Kits\<version>\WppConfig\Rev1\tracemacro.tplas a reference and add a section similar to// Functions. Such a section might look like this:// R# macros `FORALL f IN Funcs WHERE !DoubleP && !MsgArgs && !NoMsg` #undef `f.Name` #ifdef __RESHARPER__ #define `f.Name`(`f.FixedArgs`MSG, ...) ((void)(MSG, ## __VA_ARGS__)) #else #define `f.Name` WPP_(CALL) #endif `ENDFOR` `FORALL f IN Funcs WHERE !DoubleP && !MsgArgs && NoMsg` #undef `f.Name` #ifdef __RESHARPER__ #define `f.Name`(`f.FixedArgs`) ((void)0) #else #define `f.Name` WPP_(CALL) #endif `ENDFOR` `FORALL f IN Funcs WHERE DoubleP && !MsgArgs` #undef `f.Name` #ifdef __RESHARPER__ #define `f.Name`(ARGS) ((void)ARGS) #else #define `f.Name`(ARGS) WPP_(CALL) ARGS #endif `ENDFOR` `FORALL f IN Funcs WHERE MsgArgs` #undef `f.Name` #ifdef __RESHARPER__ #define `f.Name`(`f.FixedArgs`MSGARGS) ((void)(MSGARGS)) #else #define `f.Name`(`f.FixedArgs`MSGARGS) WPP_(CALL)(`f.FixedArgs`MSGARGS) #endif `ENDFOR` `FORALL r IN Reorder` #undef WPP_R`r.Name` #define WPP_R`r.Name`(`r.Arguments`) `r.Permutation` `ENDFOR`
Comments
0 comments
Please sign in to leave a comment.