What makes this header file slow VS2005 to a crawl? (IntelliSense exonerated?)
Asked Answered
G

2

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.

Gandhi answered 11/8, 2011 at 20:41 Comment(12)
Is the project using a precompiled header? Maybe you could try placing this header in it.Chromatography
Good idea, but (5 minutes of waiting later...) it didn't work.Gandhi
In VS2010 Tools > Options > Text Editor > C/C++ > Advanced I see options to disable IntelliSense and such, aren't those available in VS2005?Foramen
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).Lyndalynde
@Gandhi 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?Debbee
@Victor, See attatched code. I'm using 8.0.50727-7600 (SP.050727-7600).Gandhi
Can update to a non-bugriddled version of VS? You really should anyway.Searcy
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.Gandhi
@Gandhi Next Monday when I get back to the office I'll try the attached code (no VS on my home machine).Debbee
@Gandhi I still can't reproduce it here. Maybe you could check if you have all VS2005 fixes?Debbee
@Vitor, thanks for trying. I will try on another machine here too.Gandhi
Do you have sufficient RAM on the computer you have tested your project ?Jamshid
G
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.

Gandhi answered 23/8, 2011 at 18:43 Comment(0)
O
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?

Occur answered 23/8, 2011 at 18:35 Comment(1)
Thanks for the suggestions. I found the culprit by examining what was different between my system and a default installation.Gandhi

© 2022 - 2024 — McMap. All rights reserved.