Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 surround by #if 0 ... #endif should have a newline
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kevin.kostrzewa
New Member

USA
2 Posts

Posted - Oct 18 2012 :  08:37:04 AM  Show Profile  Reply with Quote
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.

feline
Whole Tomato Software

United Kingdom
19187 Posts

Posted - Oct 18 2012 :  5:31:16 PM  Show Profile  Reply with Quote
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?

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000