Am 30.09.2014 22:19 schrieb "Mark Morgan Lloyd" <
markmll.fpc-pas...@telemetry.co.uk>:
>
> Sven Barth wrote:
>
>> The only other alternative would be to add the RTL initialization code
to each exported function. I don't consider this a viable alternative.
>
>
> Which is more or less what Reinier's working code did. I'd hate that to
be an implicit default.
>
>
>> Note: Dynamic packages won't have this problem, because:
>> - for packages linked at compile time the initialization is run as part
of the program initialization AFTER the OS has initialized the library
(which doesn't do much in case of a package)
>> - for packages loaded at runtime it's done as part of the LoadPackage
call
>> That's however only possible, because dynamic packages are very
different from simple libraries (and stuffed with compiler magic).
>
>
> Is it possible for code in a unit to determine what sort of project it's
part of, i.e. a standalone program, a library etc.? Could the RTL have a
flag indicating that initialisation (or finalisation?) blocks were
currently being run, and anything called should assume that facilities were
restricted?

Isn't there a IsLibrary variable in System? For sure there is a IsPackage
variable which will be true if the unit is part of a package (though I
still need to find out how to implement this).
You don't need a flag for initialization/finalization blocks, because if
your code resides in one then you are obviously run inside one...

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to