RAD Studio
ContentsIndex
PreviousUpNext
CPP32.EXE, the C Compiler Preprocessor

CPP32.EXE produces a file that lists a C or C++ program, in which all #include files and #define macros have been expanded. While you do not need to use the preprocessor during normal compilation, you may find the list file helpful for debugging purposes.  

Often, when the compiler reports an error inside a macro or an include file, you can get more information about what the error is if you can see the include files or the results of the macro expansions. In many multi-pass compilers, a separate pass performs this work, and the results of the pass can be examined. Because the CodeGear C++ compiler is a single-pass compiler, use CPP32 to get the first-pass functionality found  

For each file processed by CPP32, the output is written to a file in the current directory (or the output directory named by the -n option) with the same name as the source name but with an extension of .I.  

This output file is a text file containing each line of the source file and any include files. Any preprocessing directive lines have been removed, along with any conditional text lines excluded from the compile. Unless you use a command-line option to specify otherwise, text lines are prefixed with the file name and line number of the source or include file the line came from. Within a text line, any macros are replaced with their expansion text. Use the -Sr option to produce a file which doesn't have line numbers. You can then pass this file to the compiler (use the -P compiler option to force a C++ compile).

CPP32 [<options>] <filename[s]>  

To display command line help, enter:  

cpp32 -h  

CPP32 recognizes all the same options that BCC32 does, except for the following additions for the -S option (Control preprocessed output format):

Option 
Description 
-Sc  
Keep comments in preprocessed file.  
-Sd  
Keep defines in preprocessed file.  
-Sk  
Keep output on errors.  
-Sr  
Make output readable by preserving comments and indentations  
-Ss  
Show statistics of file names and line counts.  

CPP32 can be used as a macro preprocessor; the resulting .i file can then be compiled with BCC32. The following simple program illustrates how CPP32 preprocesses a file.

Source file: HELLOFB.C

 

#define NAME “Frank CodeGear” #define BEGIN { #define END } main() BEGIN
        printf(“%s\n”, NAME);p END 

 

CPP32 Command Line

CPP32 HELLOFB.C

Output (written to HELLOFB.I)

/* HELLOFP.C 1: */  

/* HELLOFP.C 2: */  

/* HELLOFP.C 3: */  

/* HELLOFP.C 4: */  

/* HELLOFP.C 5: */main()  

/* HELLOFP.C 6: */printf("%s\n", "Frank CodeGear");  

/* HELLOFP.C 7: */}  

/* HELLOFP.C 8: */} 

MIDL (Microsoft Interface Definition Language) is an RPC compiler. In order to use MIDL with the C++ preprocessor (CPP32.EXE), you must use the following MIDL command:

Option 
Description 
-<cpp_cmd> {<CPP32>}  
Tells MIDL which preprocessor to use when processing an .IDL or .ACF file. MIDL calls the preprocessor to expand macros within source files.  
-<cpp_opt> "{<options>}"  
Specifies the command line options for the preprocessor. The -Sr option removes line number and file name information from each line of the preprocessed output. The -oCON option indicates that preprocessed output should go to standard output, instead of to file. The preprocessor banner and the current file that is being processed are not emitted. Including -oCON within a .CFG file processed by the preprocessor causes the banner to be emitted.  
{<CPP32 options>}  
Passes the options to CPP32.  
{<MIDL options>}  
Any MIDL command-line options.  
{<.idl/.acf file>  
The source file that MIDL processes.  

In some cases, CPP32 does not accept valid UUIDs. For example, a valid UUID statement is:  

uuid(5630EAA0-CA48-1067-B320-00DD010662DB)  

When CPP32 encounters 5630EAA0, it is classified as a floating-point number, and since it is an invalid floating point number, the preprocessor emits an error. To work around this problem, enclose the UUID within quotes. When using MIDL with CPP32, use the -ms_ext option. The UUID statement becomes:  

uuid("5630EAA0-CA48-1067-B320-00DD010662DB")  

and the MIDL command line becomes:  

MIDL -ms_ext -cpp_cmd CPP32 -cpp_opt " -oCON {<CPP32 options>}" {<MIDL options>} {<.idl/.acf file>}

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!