Delphi .NET (2) Database (71) Delphi IDE (89) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
Exchange Links About this site Links to us 
|
Handling of compiler definitions for a project
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Question:
What is the best way to handle the compiler definitions in a project?
Answer:
This is certainly a matter of preference. One way is to rely on the project's options and hope that the compiler always picks up these options. They're saved in the project's .DOF file in the [Compiler] section - it looks like this:
[Compiler]
A=1
B=0
C=1
D=1
E=0
I personally don't like to rely on the .DOF file for a variety of reasons. See the other tip on project files why.
Several projects of mine use conditional compilation to create a variety of different products from a single source base, e.g. 'debug', 'internal', 'shipping', 'webserver' versions.
I like to express dependencies between these conditions as shown in the example DEFS.INC file below. All .PAS files in any project start with line
{$include DEFS.INC}
I tend to build those releases with batch files that invoke the Delphi commandline compiler. These batch files also invoke perl scripts which will edit this file DEFS.INC e.g. they will insert or remove the dot (.) in selected {.$DEFINE } statements. (The purpose is that the dot turns it into a regular comment.)
If you need to quickly insert the current compiler definitions while in the Delphi IDE, you can simply press Ctrl + O + O (twice). This works in all versions Delphi 1 through Kylix. Heck, it was even available in Turbo Pascal for DOS.
You don't like the formatting? Check out SourceCoder then!
Comments:
|