Creating Libraries Callable from C

2014-04-26 Thread TJB via Digitalmars-d-learn
Is it possible to write a library that is callable from C without the enduser even knowing it was written in D? That is, can a C programmer use the library as though it were written in C straightforwardly? Or for that matter, by an enduser programming in Python or Lua where the library is

Re: Creating Libraries Callable from C

2014-04-26 Thread Rémy Mouëza via Digitalmars-d-learn
It is possible to write a D library useable from C. However, we may not be able to hide the fact that the library has been written in D. You must first export some D function you want to use from C, using extern (C) declaration. Then declare them in your C program or headers. You will also

Re: Creating Libraries Callable from C

2014-04-26 Thread Ali Çehreli via Digitalmars-d-learn
On 04/26/2014 11:27 AM, Rémy Mouëza wrote: You will also have to declare 2 function for initializing and terminating D's runtime: char rt_init(long long); char rt_term(long long); call rt_init(0) before using your D functions (this will initialize D runtime - the D GC amongst

Re: Creating Libraries Callable from C

2014-04-26 Thread ketmar via Digitalmars-d-learn
On Sunday, 27 April 2014 at 02:15:59 UTC, Ali Çehreli wrote: And if those functions are called from the library's own initialization and deinitialization functions, the C program need not know anything about the D runtime dependence: void mylib_init() { rt_init(0); // ... other