开发者

vs 2008 preprocessor defines true but code still grayed out

开发者 https://www.devze.com 2023-04-01 20:11 出处:网络
Code example #if (COMPUTER_NUMBER == PRIMARY_COMPUTER) if (platformType == NAV_BASESTATION) { nav->once(cycleno);

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 initiat开发者_JS百科e 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


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


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.

0

精彩评论

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

关注公众号