DMC to Create C .lib ?
Mike Parker
aldacron at gmail.com
Fri Mar 27 05:28:50 PDT 2009
Chris Andrews wrote:
> Sergey Gromov Wrote:
>
>> You're talking about Doryen Library project, right?
>>
>> My thought is that TCOD_console_flush is actually cdecl and must be
>> declared as extern(C), while you seem to declare it as extern(Windows)
>> which is stdcall. What you get with linkdef is corrupted stack. This
>> is why coffimplib is absolute best when you have the right COFF import
>> library: it allows to catch this sort of errors.
>
> Hah, you got me. Yeah, I'm toying with a wrapper for Doryen Library in D. I'm trying to not talk too much about it, since I don't know if I'm skilled enough to write and implement it, nor dedicated enough to finish it. :p We'll see.
>
> All the methods were preprended by TCODLIB_API, which is a typedef to __declspec(dllexport) ( or __declspec(import) ) which I thought (according to the guide) translates as export extern(Windows)
>
> I guess I'll try externing to C instead, and try to coffimp the library again. Perhaps the "visual studio" library is a bad one to use, and I should try the "Mingw" .a file.
>
The __declspec directive does not affect the calling convention, but
whether or not the function is visible outside the DLL. Any function in
a DLL that should be visible to the client program must be declared with
the __declspec directive, so you'll see that on every Windows DLL
function you interface with. You should only use extern(Windows) on the
D side when you see a function declared as stdcall (most commonly this
is done via a macro such as WINAPI, or STDCALL).
More information about the Digitalmars-d
mailing list