Closed source D libraries

Henning Pohl henning at still-hidden.de
Sun Jul 15 05:33:39 PDT 2012


On Sunday, 15 July 2012 at 12:21:23 UTC, Gor Gyolchanyan wrote:
> On Sun, Jul 15, 2012 at 4:05 PM, Henning Pohl 
> <henning at still-hidden.de>wrote:
>
>> Most closed source C and C++ libraries provide headers and 
>> binaries. It
>> seems to me that there is no way to do this in D, because the 
>> source files
>> always have to be available to import their modules.
>>
>> I'm not going to write something proprietary or closed source, 
>> but i
>> wonder if others can do so.
>>
>
> It's quite possible. All you have to do is make a module, which 
> doesn't
> contain any function bodies. The imported modules aren't 
> compiled with the
> code. Most of the time it's easier to have a single module to 
> have both the
> code to compile and symbols to import. In other cases they can 
> be separated.

Okay, so it works just like in C:

// The "header" file
module lib;

void printHelloWorld();


// The "source" file
module lib
import std.stdio;

void printHelloWorld() {
      writeln("Hello world!");
}


More information about the Digitalmars-d mailing list