INF:Line Continuation Evaluated Before Inline Comment in C 6.0

ID Number: Q62097

6.00 6.00a 6.00ax 7.00 | 6.00 6.00a

MS-DOS | OS/2

Summary:

To maintain ANSI compliance, Microsoft C version 6.0 and QuickC

versions 2.0 and later evaluate line continuation characters "\"

before inline comment tokens "//". This is a change from C version 5.1

behavior, which ignored continuation characters within inline

comments.

More Information:

Section 2.1.1.2 of the ANSI Draft proposal dated December 7, 1988

states the order in which source code translation is to take place.

The second and third steps are paraphrased below.

2. Each instance of a new-line character and an immediately

preceding backslash character is deleted, splicing physical source

lines to form logical source lines. ...

3. The source file is decomposed into preprocessing tokens and

sequences of white-space characters... Each comment is replaced by

one space character.

As this indicates, the line concatenation should be performed before

any and all evaluation of preprocessing tokens and comments. The

change in interpretation can cause problems with programs that depend

on the C 5.1 interpretation. The problem usually manifests itself in

sections of code being ignored. This can be seen in the following

program, which behaves differently under the different compilers.

Sample Code

-----------

#include<stdio.h>

#define INT1 1 // Inline comment \

#define INT2 2 // This line is ignored under C 6.0 \

void main(void)

{

printf("%d %d \n",INT1,INT2);

}

Additional reference words: 6.00 6.00a 6.00ax 7.00