在Visual Studio中禁用或修复#ifdef敏感的着色和智能感知 [英] Disable or fix #ifdef-sensitive colouring and intellisense in Visual Studio

查看:505
本文介绍了在Visual Studio中禁用或修复#ifdef敏感的着色和智能感知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:我的语法突出显示和IntelliSense损坏了.我有一个这样的C ++源文件:

#include "stdafx.hpp"

#ifdef SOMETHING
do_some_stuff;
#endif

其中stdafx.hpp(项目的预编译头)包括一个.h文件,该文件显示:

#ifdef DEFINE_SOMETHING
#define SOMETHING
#endif

DEFINE_SOMETHING在项目的项目属性中定义(在C ++/预处理器下).

Visual Studio迷失了方向,并以纯灰色显示do_some_stuff;(实际上是很多代码行)-我既没有语法着色也没有IntelliSense.

问题:我如何使Visual Studio正确(不太可能)解决这个问题,或者关闭认为它已被#ifdef淘汰的代码的事实?

(重新排列代码不是一种选择-它是一个大型而复杂的系统,其文件是在各种环境中构建的,Visual Studio只是其中之一.我使用的是Visual Studio 2005,但我想知道无论是固定的还是在以后的版本中都可以解决.)

解决方案

您描述的问题与VS 2005中的课程相当.由于完全重新设计了Intellisense系统,此问题已在Visual Studio 2010和更高版本中修复.这并不直接适用于您的问题,但以下是有关基础体系结构的信息: http://daffodil.codeplex. com ),然后使用VS 2010中的v80平台工具集构建您的项目.这使得迁移相当简单,无需任何源代码更改.

The problem: My syntax highlighting and IntelliSense are broken. I have a C++ source file like this:

#include "stdafx.hpp"

#ifdef SOMETHING
do_some_stuff;
#endif

where stdafx.hpp (the precompiled header for the project) includes a .h file that says:

#ifdef DEFINE_SOMETHING
#define SOMETHING
#endif

and DEFINE_SOMETHING is defined in the project properties for the project (under C++ / Preprocessor).

Visual Studio is losing track, and displaying do_some_stuff; (which is actually lots of lines of code) in plain grey - I have neither syntax colouring nor IntelliSense.

The question: How can I either make Visual Studio get this right (unlikely) or switch off the fact that it's greying-out code that it thinks is #ifdef'd out?

(Rearranging the code is not an option - it's a large and complex system whose files are built in various environments, Visual Studio being only one of them. I'm using Visual Studio 2005, but I'd be interested to know whether this is fixed or workaroundable in a later version.)

解决方案

The problem you describe is par for the course in VS 2005. It is fixed in Visual Studio 2010 and later due to the completely redesigned Intellisense system. This is not directly applicable to your problem, but here's some info on the underlying architecture: http://blogs.msdn.com/b/vcblog/archive/2009/05/27/rebuilding-intellisense.aspx

There are some things you could try, and some project structure changes that can help minimize the problem's frequency, but whatever you do will be hit or miss, and the problem will eventually resurface again regardless. The only real solution is to use a newer IDE.

You can continue to use the VS 2005 build tools by installing VS 2010 along with Daffodil (http://daffodil.codeplex.com), then build your projects with the v80 platform toolset in VS 2010. This makes the migration fairly straightforward, with no need for any source code changes.

这篇关于在Visual Studio中禁用或修复#ifdef敏感的着色和智能感知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆