Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 #ifdef

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
hfrmobile 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 ...
5   L A T E S T    R E P L I E S    (Newest First)
feline 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.
hfrmobile 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#
feline 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.
hfrmobile 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
feline 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.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000