home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 May / Chip_2002-05_cd1.bin / chplus / cpp / 3 / Tools.exe / cpp32.txt < prev    next >
Text File  |  1998-02-09  |  5KB  |  105 lines

  1. CPP32 Help
  2.  
  3. CPP32.EXE produces a file that lists a C program, in which all #include files and #define macros have been expanded. While you do not need to use the preprocessors during normal compilation, you may find the list file helpful for debugging purposes.
  4. 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 Borland C++ compiler is an integrated single-pass compiler, use CPP32 to get the first-pass functionality found in other compilers.
  5.  
  6. The preprocessor has a set of command-line options which control its output. For a list of these options, type CPP32 at the command line.
  7. 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.
  8. 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.
  9.  
  10. The resulting output of CPP32 cannot be compiled because of the file name and line number prefix attached to each source line. However, use the -P- 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).
  11.  
  12. CPP32.EXE uses the following command-line syntax and options:
  13.  
  14. Syntax
  15.  
  16. CPP32 [ options ] file[s]
  17.  
  18. Options
  19.  
  20. The following options can be used with CPP32:
  21.  
  22. Option    Description
  23.  
  24. -Ax    Specify language extensions
  25. -C    Allow nested comments
  26. -Dname    Define macro
  27. -gnnn    Stop after N warnings
  28. -innn    Maximum identifier length N
  29.  
  30. -Ipath    Include files directory
  31. -jnnn    Stop after N errors
  32. -npath    Output file directory
  33. -ofilename    Output file name
  34. -p    Pascal calls
  35.  
  36. -P    Include source line info (on by default)
  37. -Uname    Undefine macro
  38. -w    Enable all warnings
  39. -w-xxx    Disable warning xxx
  40. -wxxx    Enable warning xxx
  41. The -P option tells CPP32 to prefix each line with the source file name and line number. With the -P- option, CPP32 can be used as a macro preprocessor; the resulting .I file can then be compiled with BCC32. (Note that you can also use the BCC32 option -P to set default file extensions.)
  42. The following simple program illustrates how CPP32 preprocesses a file, first with -P selected, then with -P-
  43. .
  44.  
  45. Source file: HELLOFB.C
  46.  
  47. #define NAME "Frank Borland"
  48. #define BEGIN {
  49. #define END   }
  50.  
  51. main()
  52. BEGIN
  53.   printf("%s\n", NAME);
  54. END
  55.  
  56. CPP32 command line:   CPP32 HELLOFB.C
  57. Output:
  58.  
  59. HELLOAJ.c 1:
  60. HELLOAJ.c 2:
  61. HELLOAJ.c 3:
  62. HELLOAJ.c 4:
  63. HELLOAJ.c 5: main()
  64. HELLOAJ.c 6: {
  65. HELLOAJ.c 7:    printf("%s\n","Frank Borland");
  66. HELLOAJ.c 8: }
  67.  
  68. CPP32 command line:   CPP32 -P- HELLOFB.C
  69. Output:
  70.  
  71. main()
  72. {
  73.  
  74. printf("%s\n","Frank Borland");
  75.  
  76. }
  77.  
  78. MIDL (Microsoft Interface Definition Language) is an RPC compiler. In order to use MIDL, with the Borland C++ preprocessor (CPP32.EXE), you must use the following MIDL command:
  79.  
  80. MIDL -cpp_cmd {CPP32} -cpp_opt "-P- -oCON {CPP32 options}" {MIDL options} {idl/.acf}
  81.  
  82. Option    Description
  83.  
  84. -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.
  85. -cpp_opt "{options}"    Specifies the command- line options for the preprocessor. The -P- removes line number and file name information from each line of the preprocessed output. The -oCON 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.
  86.  
  87. {CPP32 options}    Passes the options to CPP32.
  88. {MIDL options}    Any MIDL command-line options.
  89. {.idl/.acf file}    The source file that MIDL processes.
  90. In some cases, CPP32 does not accept valid UUIDs. For example, a valid UUID statement is:
  91.  
  92. uuid(5630EAA0-CA48-1067-B320-00DD010662DB)
  93.  
  94.  
  95. 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 and use the -ms_ext MIDL option. The UUID statement becomes:
  96.  
  97. uuid("5630EAA0-CA48-1067-B320-00DD010662DB")
  98.  
  99. and the MIDL command line becomes:
  100.  
  101. MIDL -ms_ext -cpp_cmd {CPP|CPP32} -cpp_opt "-P- -oCON
  102.  
  103. {CPP32 options}" {MIDL options} {.idl/.acf file}
  104.  
  105. Copyright ⌐ 1998 Borland International.