Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 surround by #if 0 ... #endif should have a newline

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
kevin.kostrzewa Posted - Oct 18 2012 : 08:37:04 AM
When you surround a block of code by #if 0...#endif, you should make sure there's a newline inserted after the #endif if there's not already.

A programmer on my team used that VAssistX function and didn't have the end of the selection on the start of a line, so there was code to the right of the #endif, which the compiler ignored.

ex:
old code

...
   else if (foo())
      bar();
   else
      baz();


after modification, where selection was before the "else if" and on a space to the left of the "else"

   ...
#if 0
   else if (foo())
      bar();
#endif   else
      baz();


Now baz() was executing unconditionally because the preprocessor skips the else. Of course, we caught this quickly, but it'd be nice to have VAssistX better understand intent.

1   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Oct 18 2012 : 5:31:16 PM
If you look in the VA Snippet editor, what do you have set for the "#if" C++ snippet? The default snippet text is:

#ifdef $condition=_DEBUG$$end$
$selected$
#endif // $condition$


which has a blank line at the end, and this snippet is used when you select a block of code and press # to surround it with #if #endif. Due to this blank line at the end, the default snippet already does this.

If your snippet has a blank line at the end, but you are still seeing this problem, how are you triggering this problem, and which programming language are you working in?

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