11

When using WPP in Visual Studio (2012) each occurence of TraceEvents(...) has a wavy underline and the help text is e.g.

#define TraceEvents WPP_(CALL)
error: identifier WPP_Call_Foo_cppNNN not defined

Well, it is defined, in the .tmh header file created by the WPP preprocessor and the project compiles just fine. But Visual Studio doesn't scan and/or recognize this file.
Is there a practical way of getting rid of those squiggles?

Sam Harwell
  • 92,171
  • 18
  • 189
  • 263
VolkerK
  • 92,020
  • 18
  • 157
  • 222

3 Answers3

5

For now I work around the problem by putting

#ifdef __INTELLISENSE__
#undef TraceEvents
#define TraceEvents(a,b,...)
#endif

in one of the header files that are included after the .tmh in all of the files anyway.
The define __INTELLISENSE__ is mentioned in http://blogs.msdn.com/b/vcblog/archive/2011/03/29/10146895.aspx

VolkerK
  • 92,020
  • 18
  • 157
  • 222
  • 1
    For now I would use the condition `#if defined(__INTELLISENSE__) && defined(TraceEvents)`. I'm trying to determine if there is a way to detect Visual Studio 2013 separately from Visual Studio 2012, since the IntelliSense parser in the newer version supports your code without alteration. – Sam Harwell Apr 11 '14 at 13:22
4

Edit for Visual Studio 2012:

It appears you've reached the analysis limit of the preprocessor in Visual Studio 2012's IntelliSense engine. If you replace the TraceEvents reference with WPP_Call_Foo_cppNNN, it actually resolves the identifier without problems (until you rebuild the solution and the tmh header changes).

The solution is to load the solution in Visual Studio 2013, and choose to not upgrade the compiler toolchain, thus preserving backwards compatibility with Visual Studio 2012.


Previous Answer for Visual Studio 2013:

This was tested in Visual Studio 2013, so it may not apply to Visual Studio 2012. I couldn't find a release of the WDK that supports Visual Studio 2012, so you'll need to let me know how to configure the environment if the following steps do not work.

After building your project (to ensure the .tmh files exist), execute the Project → Rescan Solution command.

I also recommend you associate the files with the C++ editor through the following steps:

  1. Open Tools → Options... → Text Editor → File Extension
  2. Associate extension tmh with editor Microsoft Visual C++
Sam Harwell
  • 92,171
  • 18
  • 189
  • 263
3

Switch off the Live Semantic Errors in Options->Text Editor->C/C++ -> Advanced ...

Aniket Inge
  • 24,028
  • 4
  • 42
  • 74
  • 1
    Not exactly what I had in mind. "Real" or let's say "other" errors/warnings should still be marked. – VolkerK Feb 26 '13 at 16:02
  • @VolkerK unfortunately you have one or the other. You either have all warnings/errors or you have none. there is no way to specifically disable a warning/error. Suppressing such is not the way intellisense works(the way it does in say, word) – Aniket Inge Feb 26 '13 at 17:15
  • The strange thing is that the macro is defined in the same file as `TraceEvent` to which one can navigate via "Go To Definition". So I was hoping for a (hidden) "look deeper, do a full preprocessor run" option somewhere :( – VolkerK Feb 27 '13 at 09:30
  • +1 anyway, not what I was hoping for but one should not ignore the normative force of the present state ;-) – VolkerK Feb 27 '13 at 10:58
  • :-) thanks VolkerK - +1 to your question too - good question. I wonder why it didnot get enough attention – Aniket Inge Feb 27 '13 at 10:58