可以在VS2008的预处理器指令块(如#ifndef ... #endif)中启用智能感知 [英] Can intellisense be enabled in VS2008 within preprocessor directive blocks like #ifndef ... #endif

查看:149
本文介绍了可以在VS2008的预处理器指令块(如#ifndef ... #endif)中启用智能感知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C ++库中工作时,我注意到在 #ifndef CLIENT_DLL ... #endif等指令块中时,我没有任何智能感知。这显然是由于已经定义了 CLIENT_DLL这一事实。我意识到我可以通过简单地注释掉指令来解决此问题。



是否有任何智能感知选项将启用智能感知,而与指令评估无关?

解决方案

通过获得所需的东西,您会损失很多。



< Visual C ++ IntelliSense基于您想要良好/可用结果的两个主要假设。
2.您当前的IntelliSense Compiland将显示与您当前所在的配置相关的信息。



由于您当前的配置具有该预处理程序指令,因此您将无法从#ifndef区域获得结果。



如果您仔细考虑一下,这是有道理的。如果IntelliSense编译器只是尝试编译您所在的区域而不管#ifdef区域怎么办?您会得到废话和不可编译的代码。



我可以想象一个非常复杂的解决方案,它在您所在的地区运行较小的(新的)解析,仅假定该区域为compiland的一部分。但是,这种方法有很多漏洞(就像在该区域中没有声明/定义的那样),这种可能的方法会立即使您感到沮丧,除非在非常简单的情况下。



<通常,最好避免在#ifdef区域中使用逻辑,而是将参数化编译的使用委派给整个函数,以便编译器的前端始终在编译那些模块,但是链接器/优化器将选择正确的模块

希望有帮助,


While working within C++ libraries, I've noticed that I am not granted any intellisense while inside directive blocks like "#ifndef CLIENT_DLL ... #endif". This is obviously due to the fact that "CLIENT_DLL" has been defined. I realize that I can work around this by simply commenting out the directives.

Are there any intellisense options that will enable intellisense regardless of directive evaluation?

解决方案

By getting what you want, you would lose a lot.

Visual C++ IntelliSense is based on a couple major presumptions 1. that you want good/usable results. 2. that your current IntelliSense compiland will present information related to the "configuration" you are currently in.

Because your current configuration has that preprocessor directive, you will not be able to get results from the #ifndef region.

The reason makes sense if you think it through. What if the IntelliSense compiler just tried to compile the region you were in, regardless of #ifdef regions? You would get nonsense and non-compilable code. It would not be able to make heads or tails of your compiland.

I can imagine a very complex solution where it runs a smaller (new) parse on the region you are in, with only that region being assumed to be part of the compiland. However, there are so many holes in this approach (like nothing in that region being declared/defined) that this possible approach would immediately frustrate you, except in very very simple scenarios.

Generally it's best to avoid logic in #ifdef regions, and instead to delegate the usage of parameterized compilation to entire functions, so that the front-end of the compiler is always compiling those modules, but the linker/optimizer will select the correct OBJ later on.

Hope that helps, Will

这篇关于可以在VS2008的预处理器指令块(如#ifndef ... #endif)中启用智能感知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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