Am 15.07.2012 15:06, schrieb Gor Gyolchanyan:
On Sun, Jul 15, 2012 at 4:33 PM, Henning Pohl <[email protected] <mailto:[email protected]>> wrote:On Sunday, 15 July 2012 at 12:21:23 UTC, Gor Gyolchanyan wrote: On Sun, Jul 15, 2012 at 4:05 PM, Henning Pohl <[email protected] <mailto:[email protected]>>__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!"); } Exactly. Not defining a function body is perfectly fine for precisely these reasons. And, just like in C, forgetting to link with the missing body will result in a linker error. -- Bye, Gor Gyolchanyan.
The compiler can even generate those files for using the -H option. It will generate .di files. Although any formatting will get lost during that process.
Kind Regards Benjamin Thaut
