Pascal preprocessor / description
|
All examples can be found in pascal preprocessor redistributive (link to it can be found at bottom
of the page). Examples are placed in "ExN" directories (N - is example number). |
Example 1This is example of simplest usage. Just point pascal source file to preprocess. Just:ppp.exe _test.pas After executing "test.bat" file you can see output in "_test.pi" file. Look inside it and compare this file to it source "_test.pas". |
Example 2This is example uses the same "_test.pas" source file, but with extended command line options:ppp.exe -sDelphi6 -c -t -dMMM -gMMM _test.pas So we simulate Delphi6 compiler (-sDelphi6) with preprocessing conditional defines (-c), creating output file with same timestamp as original source file (-t). Next we define "MMM" symbol (-dMMM) - this is the same as you add "-%<dir>" directive to Delphi command line compiler. Adn finally instruct preprocesssor to leave directives with "MMM" in original source file. After executing "test.bat" file you could point your attention to what happened to lines of source file guarded by {$IFDEF KKK} - they got included in output file! This is because we defined "MMM" symbol and althrow we leave it in output file, but internal block guarded by {$IFDEF MMM} directive still parsed and {$DEFINE KKK} directive take action. |
Example 3This is example still uses the same "_test.pas" source file and once more extended set of parameters:ppp.exe -sDelphi6 -c -t -i -xb -dMMM -gMMM _test.pas This time we add "-i" and "-xb" switches. If you look at previous example you should see what althrow we added switch to simulate Delphi6 compiler preprocessor (-sDelphi6) output file still contains "Delphi5 or lower" string. This is because "JEDI.inc" file was not preprocessed. Now we pass "-i" to preprocess INC files what preprocessor will meet in source file. And "-xb" to let demonstrate usage of "inverting" options, so this invertion forced preprocessor not include source of all INC files except pointed by "-bXXX" parameter ("bypass" them) in main PAS file. In normal - not inverted - mode preprocessor should only "bypass" INC files pointer by "-bXXX" parameter. |
Example 4This time I'll show how to use statistic counting mode. It can be usefull to collect statistics on many files at once:ppp.exe -c -u *.pas Just look at console output. |
Example 5Comment removing feature:ppp.exe -C _test.pas "No comments." - in both means |
Example 6Unneeded preprocessor definitions removing:ppp.exe -yEXTERNALSYM -yHPPEMIT -yNODEFINE -yNOINCLUDE _test.pas And: no unsupported by Delphi3 and pre versions of Delphi nasty preprocessor directives. |
|