11

I was experimenting with a C++ project using the Compile Time Hashing technique I found here. The macros work as expected, and the compile time is reasonable, but the 64 recursive macros seem to being playing hell with Visual Studio's Intellisense. After every short edit, the IDE hangs for ~30 seconds. I suspect that it is getting wound up trying to parse the nested macros. As soon as I remove the #include "consthashmacro.h line, responsiveness returns to normal.

Is there a way to disable Intellisense for a specific header file?

I've found this article titled "Controlling IntelliSense Through Macros", but the solution there does not seem to be working correctly for me either.

Perhaps it's not intelliSense? It's definitely related to that header. Any ideas?

EDIT:
I tried disabling Intellisense entirely by renaming the feacp.dll as recommended. I get the same behavior - edits cause the IDE to hang for long periods. Removing the header restores performance. What other feature of VS2055 could be causing this incredible lag?

To Reproduce:
Using Visual Studio 2005, Create a new "Win32 Console Application" with the default settings (i.e: using precompiled headers). Add the following code to the cpp file. (Extract 'consthashmacro.h' into the source directory (available from the zip file at Chris Savoie's site)

#include "stdafx.h"

#define CONSTHASH(s) ((s)[0])
//#include "consthashmacro.h"

void Send(long hash, long value)
{
   printf("Sending %x %x\n", hash, value);
}

#define QQuot_(x) #x
#define QQuote(x) QQuot_(x)
#define Debug_Print(s, v) (Send( CONSTHASH(QQuote(__LINE__)##s), *((long*)&(v))))
int _tmain(int argc, _TCHAR* argv[])
{
       int i = __LINE__;
       float f= 3.14f;
       Debug_Print("This is a test %d", i);

       i++;
       Debug_Print("This is a test %d", i);
       Debug_Print("This was test %f", f);

    return 0;
}

When I replace the #define CONSTHASH with the include line underneath it, performance slows to a crawl.

AShelly
  • 34,686
  • 15
  • 91
  • 152
  • Is the project using a precompiled header? Maybe you could try placing this header in it. – Praetorian Aug 11 '11 at 20:46
  • Good idea, but (5 minutes of waiting later...) it didn't work. – AShelly Aug 11 '11 at 20:59
  • 1
    In VS2010 `Tools > Options > Text Editor > C/C++ > Advanced` I see options to disable IntelliSense and such, aren't those available in VS2005? – nobody Aug 12 '11 at 19:59
  • Have you given the header file to someone else who has a copy of VS2005? It would be interesting to see whether the performance problem is reproducible -- if so, you might want to post it on Microsoft Connect (even though that's probably not going to help very quickly). – stakx - no longer contributing Aug 12 '11 at 20:13
  • @AShelly I can't reproduce this here. Visual Studio 2005 (8.0.50727.867). Do you have a small project that exhibits this behavior and share it? – Vitor Py Aug 12 '11 at 20:19
  • @Victor, See attatched code. I'm using 8.0.50727-7600 (SP.050727-7600). – AShelly Aug 12 '11 at 23:47
  • Can update to a non-bugriddled version of VS? You really should anyway. – pmr Aug 13 '11 at 00:10
  • Corporate IT controls my desktop :( I made a typo, the main version number should read "-762". I'll have to look into getting the latest patches, since upgrades to 2008 or 2010 won't happen quickly here. – AShelly Aug 13 '11 at 00:26
  • @AShelly Next Monday when I get back to the office I'll try the attached code (no VS on my home machine). – Vitor Py Aug 13 '11 at 02:53
  • @AShelly I still can't reproduce it here. Maybe you could check if you have all VS2005 fixes? – Vitor Py Aug 15 '11 at 15:35
  • @Vitor, thanks for trying. I will try on another machine here too. – AShelly Aug 15 '11 at 16:33
  • Do you have sufficient RAM on the computer you have tested your project ? – Benoît Aug 16 '11 at 19:40

2 Answers2

4

I was correct that something was getting hung up on the recursive macros, but it wasn't IntelliSense. The culprit turned out to be the free version of Refactor! for C++ from DevExpress that I had installed a long while ago (and rarely used).

When I uninstalled that, IDE performance returned to normal. I re-enabled IntelliSense, and it works with no problems.

I would like to offer a formal apology to IntelliSense: I regret that I cast unfair aspersions upon you.

AShelly
  • 34,686
  • 15
  • 91
  • 152
0

More of a troubleshooting suggestion than an answer really, but:

Grab a copy of Process Explorer: http://technet.microsoft.com/en-us/sysinternals/bb896653.

Check out the process dll's, threads, sockets, open file descriptors, etc by double clicking the line where the process is listed in Process Explorer.

Also, are you redefining CONSTHASH? Try:

#ifndef CONSTHASH
    #define CONSTHASH(s) ((s)[0])
#endif

And breakpoint it to see if the line of execution skips your define. Maybe your redefining something that shouldn't be redefined?

chown
  • 51,908
  • 16
  • 134
  • 170
  • Thanks for the suggestions. I found the culprit by examining what was different between my system and a default installation. – AShelly Aug 23 '11 at 18:48