Gold mine of Visual C++ tricks!
Archive for March 31, 2008
Trailing spaces after backslash delimiter – Programmers nightmare.
Mar 31st
![]()
Usually we used to have spaces after semi columns. Since C++ ignore whitespace, its not a problem. But in Visual C++ 6.0 that is not the case always. If you put spaces after the backslash delimiter(\), it will become one of the worst bugs that you encounter.
![]()
Usually we use backslash delimiter to concatenate lines – mostly while writing macros. See the following macro.
#define INCREMENT_AND_DECREMENT( Value ) \
Value = Value + 1; \ » » »
Value = Value - 1;
In the macro, instead of » char, put some tab or space and then compile. You will get a strange error as follows.
error C2501: 'Value' : missing storage-class or type specifiers
![]()
One of the defensive mechanism is – always enable “View whitespace” by pressing Ctrl+Shift+8. So take care next time and don’t spend hrs on these silly bugs as I did years before.
![]()
Note that its just a implementation behavior in Visual C++ 6.0 and may not found in other compilers or upcoming Visual C++ versions.
Thanks to Hemant for pointing out my implicit biasing towards VisualStudio 6.0. I forgot to specify that its just a Visual studio behavior.

Targeted Audience – Intermediate.