Author |
Topic |
|
hfrmobile
Ketchup Master
Austria
79 Posts |
Posted - Aug 19 2010 : 04:48:03 AM
|
Intellisense does not respect #ifdef ...
#ifdef WIN32
#include "..\\Win32\\MyHeader.h"
#else
#include "..\\WinCE\\MyHeader.h"
#endif
WIN32 is not defined but VAX intellisense gives me the \\Win32\\MyHeader.h instead of \\WinCE\\MyHeader.h! It seems that VAX uses the first found header ... |
Visual Assist X for C/C++ and ReSharper, FxCop and StyleCop for C#, Eclipse Ganymede for Java |
Edited by - hfrmobile on Aug 19 2010 04:49:46 AM |
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Aug 19 2010 : 12:08:05 PM
|
VA does not have access to all of the preprocessor declarations, so it cannot evaluate such statements correctly. VA is designed to parse inactive code, so that it can help you when writing / editing such code.
In this situation swapping the two #include lines around may be the simplest and best answer, depending on how many files use this code. |
zen is the art of being at one with the two'ness |
|
|
hfrmobile
Ketchup Master
Austria
79 Posts |
Posted - Aug 20 2010 : 05:16:11 AM
|
Thank you for your prompt reply.
Of course this is a way (workaround) which will work in 50 percent of cases ;-) Is there really no way so that VA can access such statements? Worst case: Take the code and parse it
In the .NET world (C#) I am used to have such features (e.g. if a code is inactive through #if then this code is grayed)
Would be very nice to have such features for C++ too |
Visual Assist X for C/C++ and ReSharper, FxCop and StyleCop for C#, Eclipse Ganymede for Java |
Edited by - hfrmobile on Aug 20 2010 07:00:45 AM |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Aug 20 2010 : 09:56:56 AM
|
The general problem here is quite hard. Consider this code in a header file:
#ifdef MODE_ONE // version one of the code #else // version two of the code #endif
but sometimes in the same solution MODE_ONE is defined, and sometimes it is not defined. If the header is included in one.cpp then it is defined, and if it is included in two.cpp then it is not defined.
Sometimes #defines are defined and undefined, or changed, as you move down a cpp file.
Showing commented out code in a different colour, this is actually being done by the IDE:
IDE tools menu -> Options -> Text Editor -> C/C++ -> Formatting -> Colorize inactive code blocks in a different color
but it does not always get it right. C++ can be hard to parse at times
Turning back to your header example, approximately how often do you need to change between the two versions of the code? Every few days? Every few weeks? Or several times a day?
You might be able to replace the #include block with a macro, and use VA's StdAfx.h file to trick VA into parsing the macro the way you want. However changing this will require restarting the IDE and rebuilding VA's symbol database. So this might not be a useful idea. |
zen is the art of being at one with the two'ness |
|
|
hfrmobile
Ketchup Master
Austria
79 Posts |
Posted - Aug 23 2010 : 06:14:12 AM
|
Thanks for your reply.
Even when I use #if 0 the code is not grayed even the "Colorize inactive code blocks in a different color" is enabled.
So I'll have to live without that comport I am used with C# |
Visual Assist X for C/C++ and ReSharper, FxCop and StyleCop for C#, Eclipse Ganymede for Java |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Aug 23 2010 : 3:13:15 PM
|
Sometimes the colouring can take a few minutes to show up, and I assume requires the IDE's Intellisense parsing to be active, so if you have disabled this it is not going to work:
http://docs.wholetomato.com?W133
But I have seen rare cases where it just does not work correctly, for no obvious reason. |
zen is the art of being at one with the two'ness |
|
|
|
Topic |
|