Q40196: "*\" Viewed as Continuation Character in Comment
Article: Q40196
Product(s): See article
Version(s): 2.00
Operating System(s): MS-DOS
Keyword(s): enduser | | mspl13_c
Last Modified: 17-JAN-1989
In C, comments are delimited by /* and */. If the closing delimiter
is typed as *\ instead of */, then the backslash will be viewed as a
continuation marker. As a result, the compiler considers everything up
to the next */ as a comment. This behavior has the potential to
comment out executable instructions and data declarations, which may
not be your intent.
The following code example illustrates this situation and potential
implications:
void main()
{
/* this is a comment, but the end delimiter is incorrect *\
int temp ;
printf ("hello") ;
/* and will be interpreted as a continuation marker so the
initial comment will be viewed as ending here. */
/* This will eliminate the printf() and
the declaration of 'temp'. */
}
This is expected behavior for QuickC Version 2.00. The interpretation
of the backslash as a continuation character is similar in the
following printf() code:
printf ("Donde esta \
el bano") ;
The parsing of the string literal for this printf() will view the
backslash, "\", as a continuation marker just as the compiler will
view the backslash in "*\" as a continuation marker.
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.