INF:C/QuickC Ignore Preprocessor Directives Inside of Comments

ID Number: Q72793

5.00 5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

If a preprocessor directive is contained in a comment, the Microsoft C

and QuickC compilers may generate a message similar to the following:

fatal error C1004: unexpected end-of-file found

The exact error depends upon which directive is actually placed in the

comment.

More Information:

This is the expected behavior. The message is generated because the

compiler evaluates comments before preprocessor directives, thereby

ignoring a preprocessor directive within a comment block.

The sample code below illustrates this situation. The #endif directive

is inside of a comment because the first comment is missing a closing

comment delimiter (*/). The compiler generates a C1004 error when it

reaches the end of the file and has not encountered an #endif

directive to match the #if directive.

Sample Code

-----------

/* Compile options needed: none

*/

void main ()

{

#if 0

/* comment

printf ("here 0\n");

#endif

/* comment */

printf ("here 2\n");

}

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax 7.00