2016-04-12 12:12 GMT+02:00 Maciej Izak <hnb.c...@gmail.com>: > 2016-04-12 12:01 GMT+02:00 Maciej Izak <hnb.c...@gmail.com>: > >> To protect our management operators we should declare in System.pp: >> >> FixedAttribute = class(TCustomAttribute); // or >> SystemInitializedAttribute >> >> Now the gSomething from example is declared as: >> >> var >> [Fixed] gSomething: TSomeType; // fixed can be used only for global >> variables and for class var/{$J+} const (aka static var) >> > > Of course is still possible to obtain the error, but to achieve this you > need to really crave this. >
To to enable the complicated dependencies is possible to allow priority parameter for Fixed attribute: FixedAttribute = class(TCustomAttribute) constructor Create(aPriority: Integer = 2000); // can be default set to 2000 end; ... some module A ... var [Fixed] gFoo: TSomeType; // default priority is 2000 [Fixed(10)] gSomething: TSomeType; // lower number means higher priority, for example, first 1000 can be reserved for internal FPC usage ... somewhere in other module B, gSomething2 has Initialize operator, where gSomething is used for something... var [Fixed(100)] gSomething2: TSomeType; // has lower priority and will be initialized after gSomething and finalized before gSomething -- Best regards, Maciej Izak
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel