[vtk-developers] Multi-line comment warnings

Brad King brad.king at kitware.com
Fri Jul 26 14:52:03 EDT 2013


On 07/26/2013 02:28 PM, David Doria wrote:
> dashboard reported a bunch of "warning: multi-line comment".
> 
> // a & b \\
> 
> These trailing backslashes are the latex matrix line break

According to C++03 2.1/2 the removal of backslash-newline pairs
and combining physical lines into logical lines occurs very early
during processing, even before preprocessing starts.  Indeed:

 $ cat comment.cxx
 // 1 \\
 2
 3
 $ g++ -E -C comment.cxx
 # 1 "comment.cxx"
 # 1 "<command-line>"
 # 1 "comment.cxx"
 // 1 \2

 3

Therefore your code

 // a & b \\
 // c & d \end{array} \right)\f$
 ...

looks to the compiler as

 // a & b \// c & d \end{array} \right)\f$

 ...

This is valid but error-prone so some compilers warn about it
(gcc does with -Wall which implies -Wcomment).

I suggest using a latex %-comment at the end of the line:

 // a & b \ %

to avoid looking like a line continuation.

-Brad



More information about the vtk-developers mailing list