是什么让这个头文件使 VS2005 慢得像爬行一样? (智能感知无罪?)
我正在使用我在此处找到的编译时哈希技术来试验 C++ 项目。宏按预期工作,编译时间也合理,但 64 个递归宏似乎与 Visual Studio 的 Intellisense 玩得很不愉快。每次简短编辑后,IDE 都会挂起大约 30 秒。我怀疑它正在尝试解析嵌套宏。一旦我删除 #include "consthashmacro.h
行,响应能力就会恢复正常。
有没有办法禁用特定头文件的智能感知?
我发现这篇文章标题为 "控制 IntelliSense通过宏”,但那里的解决方案似乎对我来说也无法正常工作。
也许它不是 intelliSense?它肯定与该标头有关。有什么想法吗?
编辑:
我尝试通过 按照建议重命名 feacp.dll。我得到了同样的行为 - 编辑导致 IDE 长时间挂起。删除标头可以恢复性能。 VS2055 的其他哪些功能可能导致这种令人难以置信的延迟?
重现:
使用 Visual Studio 2005,使用默认设置(即:使用预编译头)创建一个新的“Win32 控制台应用程序”。将以下代码添加到 cpp 文件中。 (将“consthashmacro.h”提取到源目录中(可从 zip 文件中获取 在 Chris Savoie 的网站上)
#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;
}
当我用其下面的 include 行替换 #define CONSTHASH
时,性能会变得非常慢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我是正确的,递归宏上有些东西挂起了,但它不是 IntelliSense。罪魁祸首原来是免费版本的 Refactor!对于来自 DevExpress 的 C++,我很久以前就安装了(并且很少使用)。
当我卸载它时,IDE 性能恢复正常。我重新启用了 IntelliSense,它可以正常工作。
我想向 IntelliSense 正式道歉:我很遗憾对您进行了不公平的诽谤。
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.
更多的是故障排除建议而不是答案,但是:
获取 Process Explorer 的副本:http: //technet.microsoft.com/en-us/sysinternals/bb896653。
通过双击 Process Explorer 中列出进程的行来检查进程 dll、线程、套接字、打开的文件描述符等。
另外,你要重新定义 CONSTHASH 吗?尝试:
并对其设置断点以查看执行行是否跳过您的定义。也许你重新定义了一些不应该重新定义的东西?
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:
And breakpoint it to see if the line of execution skips your define. Maybe your redefining something that shouldn't be redefined?