开发者

Visual Studio Intellisense crashes due to macro file

In Visual Studio 2005, I have a .h file with preprocessor macros in it. They are apparently too complicated for Visual Studio's Intellisense because they make Visual Studio crash if they are present whereas it works fine if they are not. Does anyone know of a way to prevent Visual Studio parsing the file for Intellisense but still i开发者_运维问答nclude it in the build. By the way, I have already tried the following:

  1. Disabling Intellisense by renaming feacp.dll. Works, but impractical.
  2. Visual Assist. Works, but $250.
  3. Installing Visual Studio SP1 + the Intellisense hotfix (KB947315). Doesn't fix it (and ate 1GB of hard drive space).


The first thing to try is to install Visual Studio 2005 SP1. This fixes a lot of intellisense related issues which may help you out

  • http://msdn.microsoft.com/en-us/vstudio/bb265237.aspx

If that doesn't fix the problem try excluding the file from the project. This prevents it any any of it's contents from appearing in Visual Studio features (such as intellisense). If it's just a header file it shouldn't impact the build as the actual file won't be removed, it just won't be considered part of the project.


Ok, for the benefit of others, I'm going to solve this myself! I've been fiddling and the answer is as follows. If you have this problem, and you delete your ncb file to force Intellisense to update, you can prove to yourself that this works.

#ifdef out the offending code in your .h file as follows:

#ifdef SOMETHING_UNIQUE
<the offending code>
#endif

in the file that actually uses the macros (the cpp file that #includes the .h file):

#define SOMETHING_UNIQUE

Intellisense will now ignore the code in the .h file that causes it to crash (it will be greyed out in the editor), but it still gets compiled.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜