Thread overview | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 28, 2007 C++ Binding / extern(C++) | ||||
---|---|---|---|---|
| ||||
I was just discussing how difficult it would be for someone to write C++ bindings to a project on the dsource forums, and remembered how I wanted to use Ogre with D and wished Sinbad was done... and how DirectFB is done in C++... Has anyone figured out how to bind D to C++ on any include/importable level? (source, AST, OBJ files, extern'ing to the *.h files) If they have, maybe we can set up a project to automatically bind C++ projects in, and Walter might add it to his linker? For example, matching scrambled names by scrambling a copy of the D ones, matching it, binding it? Or perhaps if Walter allowed extern(C++) by matching the identifiers in the AST's and passed the extern(C++) segment to the digital mars C++ compiler with the shared identifiers? Just my thoughts... |
March 28, 2007 Re: C++ Binding / extern(C++) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dan | Dan wrote: > I was just discussing how difficult it would be for someone to write C++ bindings to a project on the dsource forums, and remembered how I wanted to use Ogre with D and wished Sinbad was done... and how DirectFB is done in C++... > > Has anyone figured out how to bind D to C++ on any include/importable level? (source, AST, OBJ files, extern'ing to the *.h files) > > If they have, maybe we can set up a project to automatically bind C++ projects in, and Walter might add it to his linker? > > For example, matching scrambled names by scrambling a copy of the D ones, matching it, binding it? > > Or perhaps if Walter allowed extern(C++) by matching the identifiers in the AST's and passed the extern(C++) segment to the digital mars C++ compiler with the shared identifiers? > > Just my thoughts... There already is a project to automatically bind C++ to D, it's just not particularly complete or accurate. http://www.dsource.org/projects/bcd/ The method is simple: Generate a C binding to the C++, then generate a D binding to the C. - Gregor Richards PS: extern(C++) is a terrible idea. It wouldn't be cross-compatible. |
March 29, 2007 Re: C++ Binding / extern(C++) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gregor Richards | Gregor Richards wrote:
> PS: extern(C++) is a terrible idea. It wouldn't be cross-compatible.
It amazes me that most people don't seem to realise that C++ is incompatible with C++.
|
March 29, 2007 Re: C++ Binding / extern(C++) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | Don Clugston kirjoitti: > Gregor Richards wrote: >> PS: extern(C++) is a terrible idea. It wouldn't be cross-compatible. > It amazes me that most people don't seem to realise that C++ is incompatible with C++. Yeah, even this (http://www.mozilla.org/hacking/portable-cpp.html) tells a lot. I don't know, whether I should laugh or cry. |
March 29, 2007 Re: C++ Binding / extern(C++) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jari-Matti Mäkelä | Jari-Matti Mäkelä wrote: > Don Clugston kirjoitti: >> Gregor Richards wrote: >>> PS: extern(C++) is a terrible idea. It wouldn't be cross-compatible. >> It amazes me that most people don't seem to realise that C++ is >> incompatible with C++. > > Yeah, even this (http://www.mozilla.org/hacking/portable-cpp.html) tells > a lot. I don't know, whether I should laugh or cry. Great link. It was as a result of writing this... http://www.codeproject.com/cpp/FastDelegate.asp ...that I switched to D. It seems that even the compiler writers don't know this stuff (several emailed me about it). C++ portability is a complete fiasco. |
March 29, 2007 Re: C++ Binding / extern(C++) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jari-Matti Mäkelä | Jari-Matti Mäkelä wrote:
> Don Clugston kirjoitti:
>> Gregor Richards wrote:
>>> PS: extern(C++) is a terrible idea. It wouldn't be cross-compatible.
>> It amazes me that most people don't seem to realise that C++ is
>> incompatible with C++.
>
> Yeah, even this (http://www.mozilla.org/hacking/portable-cpp.html) tells
> a lot. I don't know, whether I should laugh or cry.
That's a 9 year old document last updated 6 years ago. C++ has come a ways since then, but I'm sure there would still be plenty to leave on the list.
Dave
|
March 29, 2007 Re: C++ Binding / extern(C++) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | Don Clugston wrote:
> It was as a result of writing this...
>
> http://www.codeproject.com/cpp/FastDelegate.asp
Wait, *you're* the guy that wrote that? Great article. Even though I never actually used the technique it presents I learned a lot from it.
Also, like Walter, you look nothing like I imagined :P.
|
March 29, 2007 Re: C++ Binding / extern(C++) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frits van Bommel | Frits van Bommel wrote:
> Don Clugston wrote:
>> It was as a result of writing this...
>>
>> http://www.codeproject.com/cpp/FastDelegate.asp
>
> Wait, *you're* the guy that wrote that? Great article. Even though I never actually used the technique it presents I learned a lot from it.
>
> Also, like Walter, you look nothing like I imagined :P.
I agree with all above, great article :P.
Ironically I found that article when trying to learn how to use pointers to member functions and it helped me learn how to use them adequately. :D
|
March 29, 2007 Re: C++ Binding / extern(C++) | ||||
---|---|---|---|---|
| ||||
Posted in reply to David B. Held | David B. Held wrote:
> Jari-Matti Mäkelä wrote:
>> Don Clugston kirjoitti:
>>> Gregor Richards wrote:
>>>> PS: extern(C++) is a terrible idea. It wouldn't be cross-compatible.
>>> It amazes me that most people don't seem to realise that C++ is incompatible with C++.
>>
>> Yeah, even this (http://www.mozilla.org/hacking/portable-cpp.html) tells a lot. I don't know, whether I should laugh or cry.
>
> That's a 9 year old document last updated 6 years ago. C++ has come a ways since then, but I'm sure there would still be plenty to leave on the list.
Ah, yes - didn't notice that. I just saw "Last modified January 22, 2007" on the bottom of the page. But wait.. they have actually updated it after 2001. I'm not sure how true that is anymore, but it's still interesting to see a page like this.
|
March 30, 2007 Re: C++ Binding / extern(C++) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jari-Matti Mäkelä | Jari-Matti Mäkelä wrote: > Don Clugston kirjoitti: >> Gregor Richards wrote: >>> PS: extern(C++) is a terrible idea. It wouldn't be cross-compatible. >> It amazes me that most people don't seem to realise that C++ is incompatible with C++. Just as C compilers are not always ABI-compatible. It's just that ABIs for C are more standard than for C++. There have been, for example, good quality C compilers that used name mangling to achieve type-safe linkage. > Yeah, even this (http://www.mozilla.org/hacking/portable-cpp.html) tells a lot. I don't know, whether I should laugh or cry. I cry; most of what it says doesn't apply to compilers from about the last decade. This is what happens when languages are hugely successful (in terms of installed base) -- they gain legacy burdens. If D does things well, you don't need to spread FUD about other languages. By all means compare, but naive bashing of other languages doesn't make the D community look healthy. -- James |
Copyright © 1999-2021 by the D Language Foundation