digitalmars.D - extern(C++) and shared
- deadalnix (14/14) Nov 26 2011 I have this function :
- Jacob Carlborg (4/19) Nov 27 2011 Have you tried with __gshared instead?
- Jude Young (4/28) Nov 27 2011 yeah, I've seen this. __gshared alias extern(C++) void* function(void*)
- deadalnix (3/27) Nov 27 2011 It doesn't compile at all with __gshared. I have the following error :
- Jude Young (7/36) Nov 27 2011 extern (C++)
- deadalnix (2/40) Nov 27 2011 That does work. But isn't what is failing here.
- Martin Nowak (6/7) Nov 27 2011 Can you please file a reduced test case as bug
- deadalnix (48/55) Nov 27 2011 module fail;
- deadalnix (4/19) Nov 27 2011 According to this document :
- Martin Nowak (6/32) Nov 28 2011 =
I have this function : extern(C++) void* __dsfml_start_thread(EntryPoint entryPoint, void* userData); If EntryPoint is defined as follow : alias extern(C++) void* function(void*) EntryPoint; The function mangle in _Z20__dsfml_start_threadPFPvS_ES_ if alias extern(C++) void* function(shared void*) EntryPoint; _Z20__dsfml_start_threadPFPvPvES_ Both demangle using c++filt in __dsfml_start_thread(void* (*)(void*), void*), which is what is expected. But the definition without shared will be the only one to link successfully. Is the mangling of shared types is consistent in C++ ? shared doesn't exists in C++, so I guess we should expect the same mangling in both cases. Unless it exists some magic on the C++ side that I'm not aware of ?
Nov 26 2011
On 2011-11-27 01:20, deadalnix wrote:I have this function : extern(C++) void* __dsfml_start_thread(EntryPoint entryPoint, void* userData); If EntryPoint is defined as follow : alias extern(C++) void* function(void*) EntryPoint; The function mangle in _Z20__dsfml_start_threadPFPvS_ES_ if alias extern(C++) void* function(shared void*) EntryPoint; _Z20__dsfml_start_threadPFPvPvES_ Both demangle using c++filt in __dsfml_start_thread(void* (*)(void*), void*), which is what is expected. But the definition without shared will be the only one to link successfully. Is the mangling of shared types is consistent in C++ ? shared doesn't exists in C++, so I guess we should expect the same mangling in both cases. Unless it exists some magic on the C++ side that I'm not aware of ?Have you tried with __gshared instead? -- /Jacob Carlborg
Nov 27 2011
On Sun 27 Nov 2011 05:02:09 AM CST, Jacob Carlborg wrote:On 2011-11-27 01:20, deadalnix wrote:yeah, I've seen this. __gshared alias extern(C++) void* function(void*) EntryPoint might work. I've had TLS errors when it wasn't __gshared.I have this function : extern(C++) void* __dsfml_start_thread(EntryPoint entryPoint, void* userData); If EntryPoint is defined as follow : alias extern(C++) void* function(void*) EntryPoint; The function mangle in _Z20__dsfml_start_threadPFPvS_ES_ if alias extern(C++) void* function(shared void*) EntryPoint; _Z20__dsfml_start_threadPFPvPvES_ Both demangle using c++filt in __dsfml_start_thread(void* (*)(void*), void*), which is what is expected. But the definition without shared will be the only one to link successfully. Is the mangling of shared types is consistent in C++ ? shared doesn't exists in C++, so I guess we should expect the same mangling in both cases. Unless it exists some magic on the C++ side that I'm not aware of ?Have you tried with __gshared instead?
Nov 27 2011
Le 27/11/2011 12:02, Jacob Carlborg a écrit :On 2011-11-27 01:20, deadalnix wrote:It doesn't compile at all with __gshared. I have the following error : basic type expected, not __gsharedI have this function : extern(C++) void* __dsfml_start_thread(EntryPoint entryPoint, void* userData); If EntryPoint is defined as follow : alias extern(C++) void* function(void*) EntryPoint; The function mangle in _Z20__dsfml_start_threadPFPvS_ES_ if alias extern(C++) void* function(shared void*) EntryPoint; _Z20__dsfml_start_threadPFPvPvES_ Both demangle using c++filt in __dsfml_start_thread(void* (*)(void*), void*), which is what is expected. But the definition without shared will be the only one to link successfully. Is the mangling of shared types is consistent in C++ ? shared doesn't exists in C++, so I guess we should expect the same mangling in both cases. Unless it exists some magic on the C++ side that I'm not aware of ?Have you tried with __gshared instead?
Nov 27 2011
On Sun 27 Nov 2011 05:54:27 AM CST, deadalnix wrote:Le 27/11/2011 12:02, Jacob Carlborg a écrit :extern (C++) { __gshared type function(blah) blah; alias foo bar;? } that doesn't work?On 2011-11-27 01:20, deadalnix wrote:It doesn't compile at all with __gshared. I have the following error : basic type expected, not __gsharedI have this function : extern(C++) void* __dsfml_start_thread(EntryPoint entryPoint, void* userData); If EntryPoint is defined as follow : alias extern(C++) void* function(void*) EntryPoint; The function mangle in _Z20__dsfml_start_threadPFPvS_ES_ if alias extern(C++) void* function(shared void*) EntryPoint; _Z20__dsfml_start_threadPFPvPvES_ Both demangle using c++filt in __dsfml_start_thread(void* (*)(void*), void*), which is what is expected. But the definition without shared will be the only one to link successfully. Is the mangling of shared types is consistent in C++ ? shared doesn't exists in C++, so I guess we should expect the same mangling in both cases. Unless it exists some magic on the C++ side that I'm not aware of ?Have you tried with __gshared instead?
Nov 27 2011
Le 27/11/2011 13:17, Jude Young a écrit :On Sun 27 Nov 2011 05:54:27 AM CST, deadalnix wrote:That does work. But isn't what is failing here.Le 27/11/2011 12:02, Jacob Carlborg a écrit :extern (C++) { __gshared type function(blah) blah; alias foo bar;? } that doesn't work?On 2011-11-27 01:20, deadalnix wrote:It doesn't compile at all with __gshared. I have the following error : basic type expected, not __gsharedI have this function : extern(C++) void* __dsfml_start_thread(EntryPoint entryPoint, void* userData); If EntryPoint is defined as follow : alias extern(C++) void* function(void*) EntryPoint; The function mangle in _Z20__dsfml_start_threadPFPvS_ES_ if alias extern(C++) void* function(shared void*) EntryPoint; _Z20__dsfml_start_threadPFPvPvES_ Both demangle using c++filt in __dsfml_start_thread(void* (*)(void*), void*), which is what is expected. But the definition without shared will be the only one to link successfully. Is the mangling of shared types is consistent in C++ ? shared doesn't exists in C++, so I guess we should expect the same mangling in both cases. Unless it exists some magic on the C++ side that I'm not aware of ?Have you tried with __gshared instead?
Nov 27 2011
On Sun, 27 Nov 2011 01:20:35 +0100, deadalnix <deadalnix gmail.com> wrote:alias extern(C++) void* function(void*) EntryPointCan you please file a reduced test case as bug stating exactly what in the mangling went wrong. Not sure about the current policy of passing shared data to C++ functions. It seems to work on a promise base, then stripping the qualifiers. martin
Nov 27 2011
Le 27/11/2011 13:16, Martin Nowak a écrit :On Sun, 27 Nov 2011 01:20:35 +0100, deadalnix <deadalnix gmail.com> wrote:module fail; extern(C++) void foo1(void*); extern(C++) void bar1(shared void*); pragma(msg, foo1.mangleof); pragma(msg, bar1.mangleof); // shared is ignored here, because C++ doesn't have shared, this make sense. extern(C++) void foo2(void function(void*)); extern(C++) void bar2(void function(shared void*)); pragma(msg, foo2.mangleof); pragma(msg, bar2.mangleof); // shared is ignored here, because C++ doesn't have shared, this make sense. extern(C++) void foo3(void function(void*), void*); extern(C++) void bar3(void function(shared void*), void*); pragma(msg, foo3.mangleof); pragma(msg, bar3.mangleof); // shared generate a different mangling here. extern(C++) void foo4(void function(void*), shared void*); extern(C++) void bar4(void function(shared void*), shared void*); pragma(msg, foo4.mangleof); // Same mangling as bar3. pragma(msg, bar4.mangleof); // back to correct mangling (the one expected by g++). extern(C++) void foo5(void* function(void*), void*); extern(C++) void bar5(void* function(shared void*), void*); pragma(msg, foo5.mangleof); pragma(msg, bar5.mangleof); // shared generate a different mangling here. extern(C++) void foo6(void* function(void*), shared void*); extern(C++) void bar6(void* function(shared void*), shared void*); pragma(msg, foo6.mangleof); // shared generate a different mangling here. pragma(msg, bar6.mangleof); // function pointer mangled as in bar5, but second parameter get a "0" in the mangling that none of the mangling above had. Give the following output : _Z4foo1Pv _Z4bar1Pv _Z4foo2PFvPvE _Z4bar2PFvPvE _Z4foo3PFvPvES_ _Z4bar3PFvPvEPv _Z4foo4PFvPvEPv _Z4bar4PFvPvES_ _Z4foo5PFPvS_ES_ _Z4bar5PFPvPvES_ _Z4foo6PFPvS_EPv _Z4bar6PFPvPvES0_ Comment describe what is inconsistent (or what require something on C++ side that I'm not aware of). None is generating any warning. GDC and G++ are used here, both in 4.6.2 version (and frontend v2.055, the last supported by GDC) on linux amd64.alias extern(C++) void* function(void*) EntryPointCan you please file a reduced test case as bug stating exactly what in the mangling went wrong. Not sure about the current policy of passing shared data to C++ functions. It seems to work on a promise base, then stripping the qualifiers. martin
Nov 27 2011
Le 27/11/2011 01:20, deadalnix a écrit :I have this function : extern(C++) void* __dsfml_start_thread(EntryPoint entryPoint, void* userData); If EntryPoint is defined as follow : alias extern(C++) void* function(void*) EntryPoint; The function mangle in _Z20__dsfml_start_threadPFPvS_ES_ if alias extern(C++) void* function(shared void*) EntryPoint; _Z20__dsfml_start_threadPFPvPvES_ Both demangle using c++filt in __dsfml_start_thread(void* (*)(void*), void*), which is what is expected. But the definition without shared will be the only one to link successfully. Is the mangling of shared types is consistent in C++ ? shared doesn't exists in C++, so I guess we should expect the same mangling in both cases. Unless it exists some magic on the C++ side that I'm not aware of ?According to this document : http://www.scribd.com/doc/57293807/18/Gnu3-name-mangling S_ is used for template parameters, which is not correct here.
Nov 27 2011
On Sun, 27 Nov 2011 16:03:55 +0100, deadalnix <deadalnix gmail.com> wrot= e:Le 27/11/2011 01:20, deadalnix a =C3=A9crit :I have this function : extern(C++) void* __dsfml_start_thread(EntryPoint entryPoint, void* userData); If EntryPoint is defined as follow : alias extern(C++) void* function(void*) EntryPoint; The function mangle in _Z20__dsfml_start_threadPFPvS_ES_ if alias extern(C++) void* function(shared void*) EntryPoint; _Z20__dsfml_start_threadPFPvPvES_ Both demangle using c++filt in __dsfml_start_thread(void* (*)(void*),=void*), which is what is expected. But the definition without shared will be the only one to link successfully. Is the mangling of shared types is consistent in C++ ? shared doesn't==exists in C++, so I guess we should expect the same mangling in both cases. Unless it exists some magic on the C++ side that I'm not aware=of ?According to this document : =http://www.scribd.com/doc/57293807/18/Gnu3-name-mangling S_ is used fo=r =template parameters, which is not correct here.Thanks. http://d.puremagic.com/issues/show_bug.cgi?id=3D7024
Nov 28 2011