Collapse of whitespace by preprocessor

K

Kaleb Pederson

Hello,

Does anybody know where in the standard it allows the preprocessed
file to have whitespace removed/collapsed?

I found the following in 16.1:

"The source text is decomposed into preprocessing tokens and sequences
of white space. A single white space replaces each comment."

Is it the fact that it doesn't say that the sequences of whitespace
between tokens must be preserved?

Thanks.

--Kaleb
 
V

Victor Bazarov

Kaleb said:
Does anybody know where in the standard it allows the preprocessed
file to have whitespace removed/collapsed?

It's implementation-defined. See [lex.phases]/3.
I found the following in 16.1:

"The source text is decomposed into preprocessing tokens and sequences
of white space. A single white space replaces each comment."

Is it the fact that it doesn't say that the sequences of whitespace
between tokens must be preserved?

Yes, it is the fact. The Standard does not require preserving the
sequences of white-space characters.

V
 
K

Kaleb Pederson

Kaleb said:
Does anybody know where in the standard it allows the preprocessed
file to have whitespace removed/collapsed?

It's implementation-defined. See [lex.phases]/3.

Ahh, very nice. It's much more clearly defined there. For other
interested parties, it reads:

"Whether each nonempty sequence of whitespace characters other than
new-line is retained or replaced by one space character is
implementation defined."

Thanks.

--Kaleb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,779
Messages
2,569,606
Members
45,239
Latest member
Alex Young

Latest Threads

Top