Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi XE2: What is the purpose of IMPLICITBUILDING directive found in package

When I attempt to create a new package in Delphi XE2, there is a new construct in package dpk source file: IMPLICITBUILDING

What is that for?

package Package1;

{$R *.res}
{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION OFF}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES ON}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DEFINE DEBUG}
{$ENDIF IMPLICITBUILDING}
{$IMPLICITBUILD ON}

requires
  rtl;

end.
like image 313
Chau Chee Yang Avatar asked Sep 15 '11 07:09

Chau Chee Yang


2 Answers

Please also see this discussion: Why does Delphi change Indy's dpk source file when I change project options and this.

"The compiler directives which appear between the $IFDEF IMPLICITBUILDING and $ENDIF are normally passed as parameters by the compiler when explicitly compiling a package. Because these options change based on the configuration (debug / release) and target platform (Win32, Win64, OSX32) it's problematic to have them statically defined in the package project source. When defined in the project source they will always override the options passed by the compiler. The $IFDEF prevents these options from being used during explicit compilation.

In cases where a package is implicitly compiled these options will be used, but unless your project was saved in the configuration / target mode you want to compile for, you may not get the results you expect.

As a general rule, it's better to disable implicit building on packages and compile them explicitly via a project group build or through project dependencies. If you are building for only a single platform using a single configuration then the implicit building mechanism is adequate.

IMPLICITBUILDING is defined by the compiler during the compilation of a package that is being implicitly compiled as part of the compilation of something that depends on it. As indicated in the comment you should not be trying to define this value yourself"

like image 69
Server Overflow Avatar answered Sep 26 '22 19:09

Server Overflow


I assume it is related to the {$IMPLICITBUILD ON} flag below the conditional block. I guess that it is set as long as the compiler is performing the implicit build (compared to an explicit build). I have no idea why the settings should only be regarded if that is the case. It is certainly not documented yet.

like image 25
Rudy Velthuis Avatar answered Sep 23 '22 19:09

Rudy Velthuis