Am 10.11.2013 20:33, schrieb Walter Bright:
On 11/10/2013 4:13 AM, Benjamin Thaut wrote:
Addition: It is necessary to export the module info. Because as soon
as you
import a module and use any part of it, the compiler will reference
the module
info.

Actually, it isn't entirely clear to me why the moduleinfo needs to be
exported.

The moduleinfo is needed to run the static ctors/dtors, etc., but that
is needed by the code internal to the dll that initializes the dll.

Well if the dll initializes all the modules, it has to initialize _all_ the modules because it can't know which are used and which are not. This is most certenly the way to go when loading a D dll with the LoadLibrary windows api function(s).

But when you link against a D dll using a genereated import library there would be the option to make it behave exactly like static libraries where only modules get initiliazed, which are actually used.

Also lets assume you do not export module infos, how does the compiler know that the module is inside a dll so that the module info is not referenced? That goes against the basic design of this DIP. The entire idea was to make static / shared liraries more similar and require less effort from the user. And not the other way around. If this is not wanted we can go right back to the C/C++ way of defining both dllexport and dllimport.

Kind Regards
Benjamin Thaut

Reply via email to