Microsoft KB Archive/68834

= PRB: When Compiling with /P, Errors Are Directed to STDERR =

Article ID: 68834

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft C Professional Development System 6.0a
 * Microsoft C Professional Development System 6.0a
 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 1.5 Professional Edition
 * Microsoft Visual C++ 1.51
 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 2.0 Professional Edition
 * Microsoft Visual C++ 2.1
 * Microsoft Visual C++ 4.0 Standard Edition
 * Microsoft Visual C++ 5.0 Standard Edition
 * Microsoft Visual C++ 6.0 Service Pack 5

-



This article was previously published under Q68834





SYMPTOMS
The Microsoft C compiler can create a preprocessor listing by compiling with the /P option. If this option is used and output is redirected to a file, preprocessor error messages that are generated will go to the screen and not to the specified file.



CAUSE
This results from preprocessor errors being directed to STDERR, rather than STDOUT.

This behavior is by design. Normally the output of the compiler is syntax errors and warnings. However, when you are using the preprocessing options, the output from the compiler is the preprocessed output. Allowing preprocessor errors to be redirected would result in the errors and warnings appearing in the preprocessed file.



RESOLUTION
To resolve the problem, redirect STDERR to the file where you want the error messages to go. This can been done in MS-DOS by using a utility, such as ERROUT.EXE, which comes with C 5.1. Under OS/2 or Windows NT, the STDERR output can be redirected to a file by specifying the handle for STDERR, which is 2, followed by &quot;>&quot; and then the name of the file.



MORE INFORMATION
The examples below demonstrate the syntax. For MS-DOS, using ERROUT.EXE, use the following: ERROUT /f err.txt cl /P example.c For OS/2, Windows NT, or Windows 2000, use the following: CL /P 2>outfile.txt example.c

Additional query words: redirection 8.00 8.00c 9.00 9.10

Keywords: kbprb kbcompiler KB68834

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.