digitalmars.D - plans for interfacing to C++
- Trass3r (8/8) Jan 08 2012 There were some discussions about adding namespace support with somethin...
- Walter Bright (3/11) Jan 09 2012 I'm working as fast as I can :-)
- Zachary Lund (4/18) Jan 09 2012 How would this work exactly? Especially on Windows, libraries tend to
- Walter Bright (2/5) Jan 09 2012 Yes, as it is already.
- Trass3r (4/13) Jan 09 2012 Just wanted to point at it.
- deadalnix (2/10) Jan 09 2012 I was npot aware of this existing. This is awesome.
- Martin Nowak (6/14) Jan 09 2012 IMHO this patch is rather flawed
- Trass3r (1/3) Jan 09 2012 Hmm another difficulty is how to switch between mangling schemes.
- Zachary Lund (2/5) Jan 09 2012 Given Walter's comment, I don't think they plan to.
- Michel Fortin (12/17) Jan 09 2012 One thing that could be done is instead of the namespace argument, have
- Trass3r (5/14) Jan 09 2012 Interesting idea. But how to do it properly?
- deadalnix (3/19) Jan 10 2012 @mangled("encrypted klingon here") void foo();
- sclytrack (8/28) Jan 10 2012 It's like the vapi files. (Vala)
- Martin Nowak (7/27) Jan 10 2012 e
- Michel Fortin (17/39) Jan 10 2012 Another idea which would be much less verbose:
- Trass3r (2/15) Jan 10 2012 At least you could use extern(...) : and extern(...) {} this way.
- Trass3r (2/14) Jan 10 2012 And how is this any better than pragma??
There were some discussions about adding namespace support with something like extern(C++, namespace) IIRC. Don't know the result though. Then there's this small patch (http://d.puremagic.com/issues/show_bug.cgi?id=4620) which allows very interesting stuff, even simple templates. It's rotting. So what are the current plans? Not being able to access C++ libraries directly is a real blocker. We should really try to improve the situation.
Jan 08 2012
On 1/8/2012 7:54 PM, Trass3r wrote:There were some discussions about adding namespace support with something like extern(C++, namespace) IIRC. Don't know the result though. Then there's this small patch (http://d.puremagic.com/issues/show_bug.cgi?id=4620) which allows very interesting stuff, even simple templates. It's rotting.Wanna do a pull request for it?So what are the current plans? Not being able to access C++ libraries directly is a real blocker. We should really try to improve the situation.I'm working as fast as I can :-)
Jan 09 2012
How would this work exactly? Especially on Windows, libraries tend to not be compatible with each other. Will a C++ library be required to be compiled and linked with a certain toolset? On 01/09/2012 03:16 AM, Walter Bright wrote:On 1/8/2012 7:54 PM, Trass3r wrote:There were some discussions about adding namespace support with something like extern(C++, namespace) IIRC. Don't know the result though. Then there's this small patch (http://d.puremagic.com/issues/show_bug.cgi?id=4620) which allows very interesting stuff, even simple templates. It's rotting.Wanna do a pull request for it?So what are the current plans? Not being able to access C++ libraries directly is a real blocker. We should really try to improve the situation.I'm working as fast as I can :-)
Jan 09 2012
On 1/9/2012 1:25 AM, Zachary Lund wrote:How would this work exactly? Especially on Windows, libraries tend to not be compatible with each other. Will a C++ library be required to be compiled and linked with a certain toolset?Yes, as it is already.
Jan 09 2012
Just wanted to point at it. I'd like to have some discussion. See Martin Nowak's post for example. In the end we need a consistent way to interface with C++.Then there's this small patch (http://d.puremagic.com/issues/show_bug.cgi?id=4620) which allows very interesting stuff, even simple templates. It's rotting.Wanna do a pull request for it?I do believe that :)So what are the current plans? Not being able to access C++ libraries directly is a real blocker. We should really try to improve the situation.I'm working as fast as I can :-)
Jan 09 2012
Le 09/01/2012 04:54, Trass3r a écrit :There were some discussions about adding namespace support with something like extern(C++, namespace) IIRC. Don't know the result though. Then there's this small patch (http://d.puremagic.com/issues/show_bug.cgi?id=4620) which allows very interesting stuff, even simple templates. It's rotting. So what are the current plans? Not being able to access C++ libraries directly is a real blocker. We should really try to improve the situation.I was npot aware of this existing. This is awesome.
Jan 09 2012
Am 09.01.2012, 04:54 Uhr, schrieb Trass3r <un known.com>:There were some discussions about adding namespace support with something like extern(C++, namespace) IIRC. Don't know the result though. Then there's this small patch (http://d.puremagic.com/issues/show_bug.cgi?id=4620) which allows very interesting stuff, even simple templates. It's rotting. So what are the current plans? Not being able to access C++ libraries directly is a real blocker. We should really try to improve the situation.IMHO this patch is rather flawed - Don't construct C++ classes as value types. You would need to know the exact size of the type and D can't preserve semantics for copy and assign. - D and C++ templates don't really map.
Jan 09 2012
There were some discussions about adding namespace support with something like extern(C++, namespace) IIRC. Don't know the result though.Hmm another difficulty is how to switch between mangling schemes.
Jan 09 2012
On 01/09/2012 06:36 AM, Trass3r wrote:Given Walter's comment, I don't think they plan to.There were some discussions about adding namespace support with something like extern(C++, namespace) IIRC. Don't know the result though.Hmm another difficulty is how to switch between mangling schemes.
Jan 09 2012
On 2012-01-09 12:36:35 +0000, Trass3r <un known.com> said:One thing that could be done is instead of the namespace argument, have a mangled name argument. Then use CTFE to build the mangled name (if you want to). This would also solve the problem we have on OS X where some C functions use a mangled name with a '$' in them thanks to the use of some GCC attribute in the system headers. Or maybe it should be a pragma instead. -- Michel Fortin michel.fortin michelf.com http://michelf.com/There were some discussions about adding namespace support with something like extern(C++, namespace) IIRC. Don't know the result though.Hmm another difficulty is how to switch between mangling schemes.
Jan 09 2012
On Monday, 9 January 2012 at 18:04:58 UTC, Michel Fortin wrote:Interesting idea. But how to do it properly? A namespace or a class may have lots of functions and I really wouldn't want to be forced to write pragma(mangledName, gccmangle("Bla", ...)) before every declaration.Hmm another difficulty is how to switch between mangling schemes.One thing that could be done is instead of the namespace argument, have a mangled name argument. Then use CTFE to build the mangled name (if you want to). This would also solve the problem we have on OS X where some C functions use a mangled name with a '$' in them thanks to the use of some GCC attribute in the system headers. Or maybe it should be a pragma instead.
Jan 09 2012
Le 09/01/2012 19:19, Trass3r a écrit :On Monday, 9 January 2012 at 18:04:58 UTC, Michel Fortin wrote:mangled("encrypted klingon here") void foo(); Where encrypted klingon can be generated using CTFE.Interesting idea. But how to do it properly? A namespace or a class may have lots of functions and I really wouldn't want to be forced to write pragma(mangledName, gccmangle("Bla", ...)) before every declaration.Hmm another difficulty is how to switch between mangling schemes.One thing that could be done is instead of the namespace argument, have a mangled name argument. Then use CTFE to build the mangled name (if you want to). This would also solve the problem we have on OS X where some C functions use a mangled name with a '$' in them thanks to the use of some GCC attribute in the system headers. Or maybe it should be a pragma instead.
Jan 10 2012
On 01/10/2012 10:28 AM, deadalnix wrote:Le 09/01/2012 19:19, Trass3r a écrit :It's like the vapi files. (Vala) //encrypted klingon here. [CCode (cname = "gtk_cell_area_class_find_cell_property")] public class unowned GLib.ParamSpec find_cell_property (string property_name); //alias here With the alias in D you can use the original.On Monday, 9 January 2012 at 18:04:58 UTC, Michel Fortin wrote:mangled("encrypted klingon here") void foo(); Where encrypted klingon can be generated using CTFE.Interesting idea. But how to do it properly? A namespace or a class may have lots of functions and I really wouldn't want to be forced to write pragma(mangledName, gccmangle("Bla", ...)) before every declaration.Hmm another difficulty is how to switch between mangling schemes.One thing that could be done is instead of the namespace argument, have a mangled name argument. Then use CTFE to build the mangled name (if you want to). This would also solve the problem we have on OS X where some C functions use a mangled name with a '$' in them thanks to the use of some GCC attribute in the system headers. Or maybe it should be a pragma instead.
Jan 10 2012
On Tue, 10 Jan 2012 10:28:54 +0100, deadalnix <deadalnix gmail.com> wrot= e:Le 09/01/2012 19:19, Trass3r a =C3=A9crit :eOn Monday, 9 January 2012 at 18:04:58 UTC, Michel Fortin wrote:Hmm another difficulty is how to switch between mangling schemes.One thing that could be done is instead of the namespace argument, have a mangled name argument. Then use CTFE to build the mangled nam=(if you want to). This would also solve the problem we have on OS X where some C functions use a mangled name with a '$' in them thanks to the use of='tsome GCC attribute in the system headers. Or maybe it should be a pragma instead.Interesting idea. But how to do it properly? A namespace or a class may have lots of functions and I really wouldn=want to be forced to write pragma(mangledName, gccmangle("Bla", ...))=Quite nice. It also makes pretty clear that one is responsible to avoid symbol collisions.before every declaration.mangled("encrypted klingon here") void foo(); Where encrypted klingon can be generated using CTFE.
Jan 10 2012
On 2012-01-10 09:28:54 +0000, deadalnix <deadalnix gmail.com> said:Le 09/01/2012 19:19, Trass3r a écrit :Another idea which would be much less verbose: extern(C++, gccmangle) void foo(); Here, gccmangle is a CTFE-capable function that'd be called like this: gccmangle("foo"); So if you need a namespace argument, just add one: extern(C++, gccmangle, "bar::baz") void foo(); which would call the function like this to get the mangled name: gccmangle("foo","bar::baz"); The syntax doesn't sound quite right to me, hopefully someone can make it better. -- Michel Fortin michel.fortin michelf.com http://michelf.com/On Monday, 9 January 2012 at 18:04:58 UTC, Michel Fortin wrote:mangled("encrypted klingon here") void foo(); Where encrypted klingon can be generated using CTFE.Interesting idea. But how to do it properly? A namespace or a class may have lots of functions and I really wouldn't want to be forced to write pragma(mangledName, gccmangle("Bla", ...)) before every declaration.Hmm another difficulty is how to switch between mangling schemes.One thing that could be done is instead of the namespace argument, have a mangled name argument. Then use CTFE to build the mangled name (if you want to). This would also solve the problem we have on OS X where some C functions use a mangled name with a '$' in them thanks to the use of some GCC attribute in the system headers. Or maybe it should be a pragma instead.
Jan 10 2012
On Tuesday, 10 January 2012 at 12:09:14 UTC, Michel Fortin wrote:Another idea which would be much less verbose: extern(C++, gccmangle) void foo(); Here, gccmangle is a CTFE-capable function that'd be called like this: gccmangle("foo"); So if you need a namespace argument, just add one: extern(C++, gccmangle, "bar::baz") void foo(); which would call the function like this to get the mangled name: gccmangle("foo","bar::baz"); The syntax doesn't sound quite right to me, hopefully someone can make it better.At least you could use extern(...) : and extern(...) {} this way.
Jan 10 2012
On Tuesday, 10 January 2012 at 09:27:03 UTC, deadalnix wrote:Le 09/01/2012 19:19, Trass3r a écrit :And how is this any better than pragma??On Monday, 9 January 2012 at 18:04:58 UTC, Michel Fortin wrote:mangled("encrypted klingon here") void foo(); Where encrypted klingon can be generated using CTFE.Or maybe it should be a pragma instead.Interesting idea. But how to do it properly? A namespace or a class may have lots of functions and I really wouldn't want to be forced to write pragma(mangledName, gccmangle("Bla", ...)) before every declaration.
Jan 10 2012