I have Eclipse set up to grey out areas inside an #ifdef or #ifndef that are not complied, and I've commented my #endif s to make it clearer where my blocks are, but somewhere I've got an extra unmatched #ifdef that I cannot find.
Eclipse will highlight a code block if you double-click to the right of the { or }. Is there a way to get it to do similar thing with #ifdef blocks?
Sam
Finding the other end of #ifdef blocks
Re: Finding the other end of #ifdef blocks
Yes. See the image.
Re: Finding the other end of #ifdef blocks
Thanks Tod,
Another useful feature I didn't know about. Seems you can also do Ctrl-<Numpad/> to toggle it on and off.
I actually wanted to be able to have the block highlighted, not collapsed, but I think this would have helped me find my mis-matched #ifdef blocks as well.
Sam
Another useful feature I didn't know about. Seems you can also do Ctrl-<Numpad/> to toggle it on and off.
I actually wanted to be able to have the block highlighted, not collapsed, but I think this would have helped me find my mis-matched #ifdef blocks as well.
Sam
Re: Finding the other end of #ifdef blocks
I don't know of a way to highlight the folded code. I discovered this folding feature when trying to emulate Visual Studio's region folding, I documented the process for code region folding in Eclipse. The short version is to just combine the trick I showed you here with #if(1)/#endif. Of course it's better to keep your classes short enough that you don't need regions at all, but for some dispatch and mediator classes that can be problematic.
Re: Finding the other end of #ifdef blocks
I just stumbled on what I was looking for.
If you have code folding on but expand the section of #ifdef of interest, and you hover over the circled -, it will draw a line to the corresponding #endif. Handy when you've grabbed too many lines in a cut and paste and you end up with an "unbalanced #endif".
Sam
If you have code folding on but expand the section of #ifdef of interest, and you hover over the circled -, it will draw a line to the corresponding #endif. Handy when you've grabbed too many lines in a cut and paste and you end up with an "unbalanced #endif".
Sam
Re: Finding the other end of #ifdef blocks
If you use the Outline window (and why wouldn't you?) you'll also notice that #if and #ifdef affect that view too. Items hidden are shown with a different icon and there's an option to completely hide the inactive items. That could provide some quick forensics when looking at a large classes.