Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/Delphi/Packages    [ Add a report in this area ]  
Report #:  61968   Status: Open
incorrect units initialization in packages
Project:  Delphi Build #:  11.0.2902.10471
Version:    11.2 Submitted By:   Ilya Lazarev
Report Type:  Suggestion / Enhancement Request Date Reported:  5/10/2008 1:24:22 PM
Severity:    Infrequently encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   260925
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
3.00 out of 5
Total Votes: 1
Description
problem is mainly encountered when classes self-register in initialization parts

at least, it will be helpful, to introduce per-package compiler option that makes -LU linked package units initialization order the same as of dynamically loaded package
Steps to Reproduce:
program bugreport;
uses

Unit1;
begin
end.
--
package bugpack;
contains

Unit1,

Unit2;
end.
--
unit unit1;
interface
implementation
initialization

Writeln('Unit1.init');
end.
--
unit unit2;
interface
implementation
initialization

Writeln('Unit2.init');
end.
--
>dcc32 -CC bugpack.dpk
>dcc32 -LUbugpack -CC bugreport.dpr

run bugreport
Expected output:
Unit1.init
Unit2.init
Actual output:
Unit1.init
Workarounds
using LoadPackage function
Attachment
None
Comments

None

Server Response from: ETNACODE01