The initialization part is not called

I support the VirtualTreeView component for Delphi and C ++ Builder. Everything is fine with Delphi, but when I compile packages with C ++ Builder, the code regarding initialization in Delphi units is not called. Any ideas?

+4
source share
1 answer

When the Delphi initialization/ partitions are finalizationnot called in the C ++ Builder project, this usually means that the Delphi module is not connected to the final executable file, usually because the C ++ code is not direct referring to any code in the device, therefore it is optimized. C ++ Builder is a bit more aggressive about removing unused code than Delphi. In Delphi, just adding one to the sentence usescauses this node to bind. This is not the case in C ++. #includein a Delphi unit file .hppin C ++ code is not enough to guarantee device binding if C ++ code does not use anything from the file .hpp.

Indy , IdAllAuthentications, IdAllFTPListParsers IdAllHeaderCoders. /, , .hpp . , {$HPPEMIT} interface #pragma link .hpp. :

unit IdAllAuthentications;

interface

{
Note that this unit is simply for listing ALL Authentications in Indy.
The user could then add this unit to a uses clause in their program and
have all Authentications linked into their program.

ABSOLUTELY NO CODE is permitted in this unit.

}

{$I IdCompilerDefines.inc}

// RLebeau 2/14/09: this forces C++Builder to link to this unit so
// the units can register themselves correctly at program startup...

{$IFDEF HAS_DIRECTIVE_HPPEMIT_LINKUNIT}
  {$HPPEMIT LINKUNIT}
{$ELSE}
  {$HPPEMIT '#pragma link "IdAllAuthentications"'}
{$ENDIF}

implementation

// uses units that self-register in their initialization sections ...

end.

{$HPPEMIT LINKUNIT} XE5 Update 2, , :

: HPPEMIT Delphi ++.

...

{$ HPPEMIT LINKUNIT} #pragma iOS. . HPPEMIT.

++ {$HPPEMIT LINKUNIT} #pragma link .

Delphi , , . ++ , :

{$HPPEMIT '#pragma link "<unitname>"'}

:

{$HPPEMIT LINKUNIT}

LINKUNIT #pragma link, , / .

+7

Source: https://habr.com/ru/post/1616073/


All Articles