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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With