www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - C++ function mangling Linux GCC

reply Laeeth Isharc <laeeth laeeth.com> writes:
Am I missing something, or should extern(C++) just work for 
binding to gcc C++ on Linux.  It works fine for primitives but 
fails for pointer type arguments.  Extern "C" works fine.

Does D know how to mangle function names based on pointer types? 
I have created matching types on both sides.

Though I am using typedefs.  Eg struct Foo_; typedef struct Foo_ 
Foo; and on D side struct Foo {}

Could that be why?

What the best way to see the types of library file function 
arguments for a libfoo.a file on Linux?   Sorry for the dumb 
question.

Thanks.


Laeeth
Jan 17 2018
parent Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Thursday, 18 January 2018 at 04:16:18 UTC, Laeeth Isharc wrote:
 Am I missing something, or should extern(C++) just work for 
 binding to gcc C++ on Linux.  It works fine for primitives but 
 fails for pointer type arguments.  Extern "C" works fine.

 Does D know how to mangle function names based on pointer 
 types? I have created matching types on both sides.

 Though I am using typedefs.  Eg struct Foo_; typedef struct 
 Foo_ Foo; and on D side struct Foo {}

 Could that be why?
Yes. C++'s typedefs and using are just like D's alias. The underlying type is used in the mangling.
 What the best way to see the types of library file function 
 arguments for a libfoo.a file on Linux?   Sorry for the dumb 
 question.
nm libfoo.a | c++filt ? or https://demangler.com
Jan 17 2018