Re: How to use a function without their sources

2013-01-20 Thread Andrej Mitrovic
On 1/20/13, Jordi Sayol wrote: > Thank you for your answer. > What's the sense for extern(D)? and in which case is useful. extern(D) is the default linkage for all functions. D has its own linkage by default. The reason why is probably to allow the compiler to optimize the way the functions are c

Re: How to use a function without their sources

2013-01-20 Thread Jordi Sayol
Al 18/01/13 21:32, En/na Andrej Mitrovic ha escrit: > On 1/18/13, nazriel wrote: >> Show me a working solution to question from first post. >> >> "How to use existing static D library *WITHOUT* using .DI files". >> You can't edit library itself, so adding extern(C) to functions >> won't work. >> Y

Re: How to use a function without their sources

2013-01-18 Thread Andrej Mitrovic
On 1/18/13, nazriel wrote: > There were 2 types of answers in this topic: > 1) Yes, you can if functions in library are marked as extern(C) You still have to provide .d or .di files, you can't expect the user to have to manually write extern declarations. > 2) Yes, you can even if functions are

Re: How to use a function without their sources

2013-01-18 Thread nazriel
On Friday, 18 January 2013 at 20:33:04 UTC, Andrej Mitrovic wrote: On 1/18/13, nazriel wrote: Show me a working solution to question from first post. "How to use existing static D library *WITHOUT* using .DI files". You can't edit library itself, so adding extern(C) to functions won't work.

Re: How to use a function without their sources

2013-01-18 Thread Andrej Mitrovic
On 1/18/13, nazriel wrote: > Show me a working solution to question from first post. > > "How to use existing static D library *WITHOUT* using .DI files". > You can't edit library itself, so adding extern(C) to functions > won't work. > You can't create .DI file - which is the main question from f

Re: How to use a function without their sources

2013-01-18 Thread anonymous
On Friday, 18 January 2013 at 17:47:42 UTC, nazriel wrote: lib.d: extern(C) void printf(const char*, ...); void foo() { printf("%s".ptr, "hi".ptr); } test.d: extern(C) void _D3lib3fooFZv(); void main() { _D3lib3fooFZv(); } On Friday, 18 January 2013 at 18:18:07 UTC, Andrej

Re: How to use a function without their sources

2013-01-18 Thread nazriel
On Friday, 18 January 2013 at 18:44:29 UTC, Andrej Mitrovic wrote: On 1/18/13, nazriel wrote: So don't take this serious. This is D.learn, so people expect to get valid information here and they don't know if you're showing an invalid example or not unless you tell them. It's valid examp

Re: How to use a function without their sources

2013-01-18 Thread Andrej Mitrovic
On 1/18/13, nazriel wrote: > So don't take this serious. This is D.learn, so people expect to get valid information here and they don't know if you're showing an invalid example or not unless you tell them.

Re: How to use a function without their sources

2013-01-18 Thread nazriel
On Friday, 18 January 2013 at 18:34:24 UTC, Jordi Sayol wrote: Al 18/01/13 18:47, En/na nazriel ha escrit: On Friday, 18 January 2013 at 17:02:51 UTC, Jordi Sayol wrote: Is there a way to use a function from a static D library without importing their D sources nor their DI interface? lib.d:

Re: How to use a function without their sources

2013-01-18 Thread nazriel
On Friday, 18 January 2013 at 18:23:57 UTC, nazriel wrote: On Friday, 18 January 2013 at 18:18:07 UTC, Andrej Mitrovic wrote: On 1/18/13, nazriel wrote: extern(C) void _D3lib3fooFZv(); void main() { _D3lib3fooFZv(); } That's a *terrible* idea, you are calling a D function using the

Re: How to use a function without their sources

2013-01-18 Thread Jordi Sayol
Al 18/01/13 18:47, En/na nazriel ha escrit: > On Friday, 18 January 2013 at 17:02:51 UTC, Jordi Sayol wrote: >> Is there a way to use a function from a static D library without importing >> their D sources nor their DI interface? > > lib.d: > > extern(C) void printf(const char*, ...); > > void

Re: How to use a function without their sources

2013-01-18 Thread nazriel
On Friday, 18 January 2013 at 18:23:03 UTC, Johannes Pfau wrote: Am Fri, 18 Jan 2013 19:17:33 +0100 schrieb "nazriel" : [...] Nice! This should be mentioned at Language Reference, so it won't get lost. Isn't this documented? I thought it was well known that you can mark D functions as e

Re: How to use a function without their sources

2013-01-18 Thread nazriel
On Friday, 18 January 2013 at 18:18:07 UTC, Andrej Mitrovic wrote: On 1/18/13, nazriel wrote: extern(C) void _D3lib3fooFZv(); void main() { _D3lib3fooFZv(); } That's a *terrible* idea, you are calling a D function using the C convention, you're going to have all sorts of problems.

Re: How to use a function without their sources

2013-01-18 Thread Johannes Pfau
Am Fri, 18 Jan 2013 19:17:33 +0100 schrieb "nazriel" : > [...] > > Nice! > This should be mentioned at Language Reference, so it won't get > lost. > Isn't this documented? I thought it was well known that you can mark D functions as extern(C). It's needed when implementing callback functions f

Re: How to use a function without their sources

2013-01-18 Thread Johannes Pfau
Am Fri, 18 Jan 2013 18:47:41 +0100 schrieb "nazriel" : > lib.d: > void foo() { > printf("%s".ptr, "hi".ptr); > } > > test.d: > extern(C) void _D3lib3fooFZv(); > I think this is dangerous, there's no guarantee that extern(D) equals extern(C). > How to handle name > mangling? > Maybe

Re: How to use a function without their sources

2013-01-18 Thread nazriel
On Friday, 18 January 2013 at 18:10:35 UTC, Maxim Fomin wrote: On Friday, 18 January 2013 at 17:47:42 UTC, nazriel wrote: On Friday, 18 January 2013 at 17:02:51 UTC, Jordi Sayol wrote: Is there a way to use a function from a static D library without importing their D sources nor their DI interf

Re: How to use a function without their sources

2013-01-18 Thread Andrej Mitrovic
On 1/18/13, nazriel wrote: > extern(C) void _D3lib3fooFZv(); > > void main() { > _D3lib3fooFZv(); > } That's a *terrible* idea, you are calling a D function using the C convention, you're going to have all sorts of problems. extern(D) is not just used for mangling, it's also used for design

Re: How to use a function without their sources

2013-01-18 Thread Maxim Fomin
On Friday, 18 January 2013 at 17:47:42 UTC, nazriel wrote: On Friday, 18 January 2013 at 17:02:51 UTC, Jordi Sayol wrote: Is there a way to use a function from a static D library without importing their D sources nor their DI interface? lib.d: extern(C) void printf(const char*, ...); void fo

Re: How to use a function without their sources

2013-01-18 Thread nazriel
On Friday, 18 January 2013 at 17:02:51 UTC, Jordi Sayol wrote: Is there a way to use a function from a static D library without importing their D sources nor their DI interface? lib.d: extern(C) void printf(const char*, ...); void foo() { printf("%s".ptr, "hi".ptr); } test.d: exter

Re: How to use a function without their sources

2013-01-18 Thread Rob T
On Friday, 18 January 2013 at 17:02:51 UTC, Jordi Sayol wrote: Is there a way to use a function from a static D library without importing their D sources nor their DI interface? Yes you should be able to do it, but not everything can be imported without the source code, for example function te

How to use a function without their sources

2013-01-18 Thread Jordi Sayol
Is there a way to use a function from a static D library without importing their D sources nor their DI interface? -- Jordi Sayol