digitalmars.D - Calling a non-mangled C function?
- Jarrett Billingsley (7/7) Jan 02 2005 I have a lib that was compiled in C, and the names are NOT mangled. So ...
- Jarrett Billingsley (3/3) Jan 02 2005 Neeevermind, found out I could do it with an IMPORTS directive in the .d...
- Stewart Gordon (8/11) Jan 02 2005 What happened to the return type? Should this compile?
- Jarrett Billingsley (10/12) Jan 02 2005 I just typed the code, didn't copy and paste ;) I realized that there w...
- Walter (6/13) Jan 03 2005 is
- Jarrett Billingsley (2/5) Jan 03 2005 My bad. But using extern(C) still doesn't help the problem - then it lo...
I have a lib that was compiled in C, and the names are NOT mangled. So no _Function 4, just Function. How do I call this from D? In my D code, I have the line: extern (C) Function(int whatever); and when I link, the linker likes the library, but my program's obj file is looking for _Function 4, when it should be looking for an unmangled name. How on earth can I get it to look for the unmangled name?
Jan 02 2005
Neeevermind, found out I could do it with an IMPORTS directive in the .def file. WOW am I overjoyed :D
Jan 02 2005
Jarrett Billingsley wrote: <snip>extern (C) Function(int whatever);What happened to the return type? Should this compile?and when I link, the linker likes the library, but my program's obj file is looking for _Function 4, when it should be looking for an unmangled name.This looks like a bug to me. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on on the 'group where everyone may benefit.
Jan 02 2005
What happened to the return type? Should this compile?I just typed the code, didn't copy and paste ;) I realized that there was no return type after I posted it, but there is no Edit Post function here, and I figured no one would really notice..This looks like a bug to me.Maybe not a bug, but an oversight. Perhaps Walter didn't know that it was possible to have unmangled names..? Anyway, it was a very simple fix (in my def file, all I had to put was an IMPORTS _Function 4=<libname>.Function). Still, would be nice to not have to do that, though I'm not sure how it'd translate from the matching C++ code that generated the lib - "extern "C" __declspec(dllexport)". I though that "extern (C) export" would do it, but apparently not..
Jan 02 2005
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message news:cr9807$2ntf$1 digitaldaemon.com...I have a lib that was compiled in C, and the names are NOT mangled. So no _Function 4, just Function. How do I call this from D? In my D code, I have the line: extern (C) Function(int whatever); and when I link, the linker likes the library, but my program's obj fileislooking for _Function 4, when it should be looking for an unmangled name. How on earth can I get it to look for the unmangled name?_Function 4 is mangled with the: extern (Windows) mangling.
Jan 03 2005
_Function 4 is mangled with the: extern (Windows) mangling.My bad. But using extern(C) still doesn't help the problem - then it looks for _Function.
Jan 03 2005