Compartilhar via


Creating a Preprocessed Listing

You can create a preprocessed listing of a source file by specifying the preprocessed (.pp) file name extension to the NMAKE command. To run an NMAKE command, you must either have a makefile in your sources directory, or else explictly include the path to a default makefile (makefile.def). To create a preprocessed listing when you have a makefile in your sources directory, run the following command from a Windows Driver Kit (WDK) build environment window:

nmake source-file-name.pp

To create a preprocessed listing when you do not have a makefile in your sources directory, you must specifiy the default makefile (makefile.def). Run the following command from a Windows Driver Kit (WDK) build environment window:

 nmake /f %NTMAKEENV%\makefile.def source-file-name.pp

The NMAKE utility calls the C/C++ preprocessor and sets a rule that directs the preprocessor to create a preprocessed listing. In the .pp file, you can see the structures, where they are defined, and whether NMAKE retrieved header files from the correct location.

For example, if you have a source file that is named MyFile.c, you can create a preprocessed listing of that source file by running the following command from the WDK build environment:

nmake MyFile.pp

The C/C++ preprocessor adds line numbers to the preprocessed listing file. You can use these line numbers to determine whether NMAKE retrieved header files from the correct location, and which #define directives and structures it added.

Preprocessing also adds #line directives to the output file at the beginning and end of each included file, and around lines removed by preprocessor directives that specify conditional compilation.

The preprocessed listing file is identical to the original source file, except that the compiler performs all preprocessor directives and performs macro expansions. The #line directives are the line numbers in the file where the preprocessor directives or macros were found.

Each C/C++ #include directive within the source file is handled as a copy-and-paste of the included header file. The C/C++ preprocessor adds the included data into the main source file at the line where the #include directive is located.

Note  The C/C++ preprocessor replaces comment lines in the included header files with blank lines in the .pp file.

The following example uses the Toaster sample (Toaster.c) in the src\general\toaster\wdm\featured1 directory of the WDK. If the following command is entered from the command-line of the WDK build environment, the C/C++ preprocessor creates a file that is named Toaster.pp in the same directory where Toaster.c resides:

nmake Toaster.pp

The following example shows an excerpt from the preprocessor listing in Toaster.pp. In this excerpt, line 61 of Toaster.c contains an #include directive for the Wdftypes.h header file. The C/C++ preprocessor includes the Wdftypes.h header file within the generated .pp file and replaces the comment lines in Wdftypes.h file with blank lines in the .pp file:

#line 61 "c:\\winddk\\7063.0\\inc\\wdf\\kmdf\\1.9\\wdftypes.h"






typedef enum _WDF_TRI_STATE {
    WdfFalse = 0,
    WdfTrue = 1,
    WdfUseDefault = 2,
} WDF_TRI_STATE, *PWDF_TRI_STATE;



typedef PVOID WDFCONTEXT;




typedef struct WDFDEVICE_INIT *PWDFDEVICE_INIT;

typedef struct _WDF_OBJECT_ATTRIBUTES *PWDF_OBJECT_ATTRIBUTES;

 

 

Send comments about this topic to Microsoft

Build date: 5/3/2011