vs 2008 预处理器定义 true 但代码仍然呈灰色

发布于 2024-12-02 04:23:31 字数 571 浏览 0 评论 0原文

代码示例

#if (COMPUTER_NUMBER == PRIMARY_COMPUTER)
if (platformType == NAV_BASESTATION) {
    nav->once(cycleno);      
    controller->once(cycleno);      

等。#if 下面的所有内容均呈灰色。我有一个很大的代码库,其中包含许多此类宏。该代码有多个版本,具体取决于由几个关键参数管理的目标,如下所示。尽管在项目设置中定义了宏,尽管我尝试将其设置在代码文件中以供智能感知发现,并且尽管我重置了 vs 设置以启动新的智能感知扫描,但代码块仍呈灰色且无法显示通过智能感知运行。我已经下载了视觉辅助试用版,正在尝试看看它是否适合。

我尝试在上面粘贴的代码行上方添加 #define COMPUTER_NUMBER = PRIMARY_COMPUTER 并保存并关闭并重新打开 vs 希望启动新的智能感知扫描,但似乎没有任何反应。之后我什至可以对宏名称使用智能感知,然后说转到定义,这会将我带到将宏定义为该值的位置,但众所周知,这是一个顽固的野兽。我应该尝试或澄清什么吗?

谢谢

Code example

#if (COMPUTER_NUMBER == PRIMARY_COMPUTER)
if (platformType == NAV_BASESTATION) {
    nav->once(cycleno);      
    controller->once(cycleno);      

etc. Everything below the #if is grayed out. I have a large code base that consists of many of these types of macros. The code has multiple versions depending on the target as managed by a few key parameters like this. Despite the macro being defined in the project settings, and despite my attempts to set it in a code file for intellisense to discover, and despite my resetting of vs settings to initiate a fresh intellisense scan, the code block is grayed out and can't be run through with intellisense. I've downloaded the trial of visual assist and am trying to see if it will suit.

I've tried adding #define COMPUTER_NUMBER = PRIMARY_COMPUTER right above such code lines as pasted above and saving and closing and reopening vs in hopes of initiating a new intellisense scan, but nothing seems to happen. I can even use intellisense on the macro name after that and say go to definition which brings me to where I've defined the macro to be that value, but this is an obstinate beast as we all know. Anything I should try, or clarify?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

往日 2024-12-09 04:23:31

不是预处理器问题的修复,但您可以简单地禁用灰显代码功能。取消选中
工具 |选项|文本编辑器 | C/C++ |格式化 |用不同的颜色为非活动代码块着色

Not a fix for the preprocessor problem, but you could simply disable the grayed out code feature. Uncheck
Tools | Options | Text Editor | C/C++ | Formatting | Colorize inactive code blocks in a different color

楠木可依 2024-12-09 04:23:31

我知道这已经很旧了,但我仍然遇到问题。我有一个项目,其中定义了预处理器“BLUETOOTH”,但源文件的整个部分呈灰色。它仍然按照应有的方式构建,但很烦人,因为它很难阅读,并且没有一个 #pragma 区域起作用,所以我无法将其放入概述的形式。

我能够解决这个问题的唯一方法是进入项目的属性,删除预处理器蓝牙,点击应用,然后将其添加回来并点击应用。然后所有变灰的文本都恢复为正常颜色。

因为这似乎是一个错误,所以我不知道该方法能否很好地解决我所看到的与此问题相关的其他人的问题,但它对我有用。

对我来说,一个更大的问题是智能感知在灰色文本中不起作用(它充当非活动状态),但编译正确地构建了灰色代码。

I know this is old but I still had the problem. I had a project where the preprocessor 'BLUETOOTH' was defined but the source file had the whole section grayed out. It still built as it should but it was annoying because it was hard to read and none of the #pragma regions worked so I could not put it into outlined form.

The only way I was able to work around this was to go into the properties for the project, remove the preprocessor BLUETOOTH, hit apply, and then add it back and hit apply. And then all that grayed out text was set back to normal colors.

Since this seems to be a bug I don't know how well the approach will solve other people's problems I have seen reported with this issue, but it worked for me.

A bigger problem for me is that intellisense did NOT work in the grayed out text (it acted as inactive) but the compilation correctly built the grayed out code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文