Re# C++ Syntax Parsing and " __INTELLISENSE__"

I write kernel-mode software (like device drivers and file system minifilters) for Windows.  A commonly used feature that's available to Windows kernel-mode developers is something called WPP Tracing.  This feature dynamically creates (a long series of obtuse) macros that are defined in a build-time created created file, with definitions like this:

// Functions
#undef DoDebugTrace
#ifdef __INTELLISENSE__
#define DoDebugTrace(TRACELEVEL, MSG, ...) ((void)(MSG, ## __VA_ARGS__))
#else
#define DoDebugTrace WPP_(CALL)
#endif
#undef DoTraceMessage
#ifdef __INTELLISENSE__
#define DoTraceMessage(LEVEL, MSG, ...) ((void)(MSG, ## __VA_ARGS__))
#else
#define DoTraceMessage WPP_(CALL)
#endif
 

Note that use of #ifdef __INTELLISENSE__ in the above.

When Re# encounters the invocation of these macros in source code, Re# of course flags them with an error “Cannot resolve symbol ‘WPP_<something here>’ "

This is super annoying and results in dozens of red-squiggle underlines in a typical source code file.

Is there ANY work-around that I could use that'll get Re# C++ to NOT flag these macros?  Is there any reason that Re# can't define __INTELLISENSE__ when it does its very clever syntax parsing?  Maybe, even, as an option or something?

This problem affects just about anybody who does Windows driver development AND uses Re# C++… I get that we're a small community, but it seems like this problem might occur in user-land in places as well.

0
4 comments

Hello Petergv,

Thank you for the detailed description.

You can use the same approach in ReSharper. ReSharper has a macro that is similar to __INTELLISENSE__ called __RESHARPER__, so you can use something like:

#undef DoDebugTrace
#ifdef __RESHARPER__
#define DoDebugTrace(TRACELEVEL, MSG, ...) ((void)(MSG, ## __VA_ARGS__))
#else
#define DoDebugTrace WPP_(CALL)
#endif
#undef DoTraceMessage
#ifdef __RESHARPER__
#define DoTraceMessage(LEVEL, MSG, ...) ((void)(MSG, ## __VA_ARGS__))
#else
#define DoTraceMessage WPP_(CALL)
#endif

Directly in the code or create/modify the templates used to generate .tmh.

As an example, a template snippet for ReSharper 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`

Let me know if you encounter any issues in your environment using this method.

0

Thanks for the reply.


The problem is that this is a system supplied, build-time generated, file.  So, I can’t change the definition.


Could I, perhaps, in another header, do:


#ifdef __RESHARPER__
#define __INTELLIESENSE__
#endif


Would you anticipate any issues with that?

0

Petergv, Thank you for the information. 

 

Would you mind setting __INTELLIESENSE__=1 in Project Properties under ReSharper? It should help with WPP macro resolution without source code changes.

0

Ah, HA!  THAT WORKS!

THANK you… I really appreciate you taking the time to look into this (I see you tested with the wdfserial example… excellent).

You have solved what has been a long-standing annoyance for me.  I'm super grateful. :-)

0

Please sign in to leave a comment.