Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 02, 2003 D library "headers" | ||||
---|---|---|---|---|
| ||||
Sorry if this has come up, or I've missed it somewhere. Lets for a moment assume that I want to write a library in D, compile it and distribute it as binary only. How would I go about letting other apps link to that library? So if I have void someFunc(void) in my library, could I distribute a D module that had extern (D) void someFunc(void); in it? Is it the same for classes. extern (D) class Foo;? Cheers Brad |
December 03, 2003 Re: D library "headers" | ||||
---|---|---|---|---|
| ||||
Posted in reply to brad beveridge | Have a look at the Synsoft libraries that Metthew Wilson created. You have to maintain two sets of .d files one with the implementation and another with just function declarations within a extern (D) {} block. "brad beveridge" <brad@nospam.com> wrote in message news:bqisas$2t6q$1@digitaldaemon.com... > Sorry if this has come up, or I've missed it somewhere. > Lets for a moment assume that I want to write a library in D, compile it > and distribute it as binary only. How would I go about letting other > apps link to that library? > So if I have void someFunc(void) in my library, could I distribute a D > module that had > extern (D) void someFunc(void); > in it? > > Is it the same for classes. > extern (D) class Foo;? > > Cheers > Brad > |
December 03, 2003 Re: D library "headers" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Julio César Carrascal Urquijo | Sorry, it should be Matthew Wilson and the SynSoft libraries are located at http://synesis.com.au/synsoft/d.html. |
December 03, 2003 Re: D library | ||||
---|---|---|---|---|
| ||||
Posted in reply to Julio César Carrascal Urquijo | In article <bqjae4$ftv$1@digitaldaemon.com>, Julio César Carrascal Urquijo says... > >Have a look at the Synsoft libraries that Metthew Wilson created. > >You have to maintain two sets of .d files one with the implementation and another with just function declarations within a extern (D) {} block. > No chance. I have a file 'types.d' with the following declaration: extern (D) { class test; } In a other source file 'myfunc.d': import types; void myfunc() { test xx = new test; } compile: dmd -c myfunc.d compiler says: types.d: class test is forward referenced Bye Uwe |
December 03, 2003 Re: D library | ||||
---|---|---|---|---|
| ||||
Posted in reply to uwem | You would have to provide a full class declaration, with forward-declared member functions. You cannot instantiate forward-declared classes. It would be nice if the compiler would just go out and discover the class properties by looking at .obj file records, instead of having to parse it through a text file. But the point of these "headers" is to tell one how to use the library, and "module mylib; class foo;" doesn't tell you much about how mylib's foo objects work. Just knowing the class exists does not give you enough information to even construct an instance of the class, because you might need to provide parameters. Sean "uwem" <uwem_member@pathlink.com> wrote in message news:bqjv5v$1f70$1@digitaldaemon.com... > In article <bqjae4$ftv$1@digitaldaemon.com>, Julio César Carrascal Urquijo says... > > > >Have a look at the Synsoft libraries that Metthew Wilson created. > > > >You have to maintain two sets of .d files one with the implementation and another with just function declarations within a extern (D) {} block. > > > No chance. I have a file 'types.d' with the following declaration: > > extern (D) > { > class test; > } > > In a other source file 'myfunc.d': > > import types; > > void myfunc() > { > test xx = new test; > } > > compile: dmd -c myfunc.d > compiler says: types.d: class test is forward referenced > > Bye > Uwe |
December 03, 2003 Re: D library "headers" | ||||
---|---|---|---|---|
| ||||
Posted in reply to brad beveridge | It is enough to declare everything without extern, but you would leave the code out, just as with C++.
digc, the compiler driver which comes with dig library by Burton Radons (www.opend.org) can strip away function/method bodies. What you get is fairly equivalent to headers.
In future, binary symbol tables might be implemented, which would solve the problem completely, but it is simply too early to think of such things right now...
-eye
brad beveridge wrote:
> Sorry if this has come up, or I've missed it somewhere.
> Lets for a moment assume that I want to write a library in D, compile it and distribute it as binary only. How would I go about letting other apps link to that library?
> So if I have void someFunc(void) in my library, could I distribute a D module that had
> extern (D) void someFunc(void);
> in it?
>
> Is it the same for classes.
> extern (D) class Foo;?
>
> Cheers
> Brad
>
|
December 26, 2003 Re: D library "headers" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ilya Minkov | "Ilya Minkov" <minkov@cs.tum.edu> wrote in message news:bqlev1$j5p$1@digitaldaemon.com... > In future, binary symbol tables might be implemented, which would solve the problem completely, but it is simply too early to think of such things right now... D is designed so that module imports can be implemented by loading some vendor-defined precompiled symbol table binary file. I was going down the road implementing one such for DMD, until I realized that the lexer/parser is so fast that it made more sense to just parse the original source for the symbols. |
December 27, 2003 Re: D library "headers" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | If the original source file is smaller, you're probably right :) Sean "Walter" <walter@digitalmars.com> wrote in message news:bsgs2r$spd$1@digitaldaemon.com... > > "Ilya Minkov" <minkov@cs.tum.edu> wrote in message news:bqlev1$j5p$1@digitaldaemon.com... > > In future, binary symbol tables might be implemented, which would solve the problem completely, but it is simply too early to think of such things right now... > > D is designed so that module imports can be implemented by loading some vendor-defined precompiled symbol table binary file. I was going down the road implementing one such for DMD, until I realized that the lexer/parser is so fast that it made more sense to just parse the original source for the > symbols. |
Copyright © 1999-2021 by the D Language Foundation