Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes, your expected result is the one required by the C and C++ standards. The backslash simply escapes the newline, i.e. the backslash-newline sequence is deleted.</p> <p>GCC 4.2.1 from my OS X installation gives the expected result, as does Clang. Furthermore, adding a <code>#define</code> to the beginning and testing with</p> <pre><code>#define main(){\ return 0; } main() </code></pre> <p>yields the correct result</p> <pre><code>} {return 0; </code></pre> <p>Perhaps <code>gcc -E</code> does some extra processing after preprocessing and before outputting it. In any case, the line break seen by the rest of the preprocessor seems to be in the right place. So it's a cosmetic bug.</p> <p><strong>UPDATE:</strong> According to the <a href="http://gcc.gnu.org/wiki/FAQ#cpp_continuation_discarded" rel="noreferrer">GCC FAQ</a>, <code>-E</code> (or the default setting of the <code>cpp</code> command) attempts to put output tokens in roughly the same visual location as input tokens. To get "raw" output, specify <code>-P</code> as well. This fixes the observed issues.</p> <p>Probably what happened:</p> <ol> <li>In preserving visual appearance, tokens not separated by spaces are kept together.</li> <li>Line splicing happens before spaces are identified for the above.</li> <li>The <code>{</code> and <code>return</code> tokens are grouped into the same visual block.</li> <li><code>0</code> follows a space and its location on the next line is duly noted.</li> </ol> <p><strong>PLUG:</strong> If this is really important to you, I have implemented <a href="http://code.google.com/p/c-plus" rel="noreferrer">my own preprocessor</a> with correct implementation of both raw-preprocessed and whitespace-preserving "pretty" modes. Following this discussion I <a href="http://code.google.com/p/c-plus/source/detail?r=d462b650c355b606545158f4da7365180b699752" rel="noreferrer">added</a> line splices to the preserved whitespace. It's not really intended as a standalone tool, though. It's a testbed for a compiler framework which happens to be a fully compliant C++11 preprocessor library, which happens to have a miniature command-line driver. (The error messages are on par with GCC, or Clang, sans color, though.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload