------- Comment #10 from dannysmith at users dot sourceforge dot net  
2007-03-10 01:51 -------
In dlls buit by MS windows native toolchain (eg the win32api system
libraries), exported functions are built with __stdcall calling
convention, but are exported without any decoration, eg, WinFooFoo is
simply WinFooFoo. I believe this is a legacy of use of Pascal language
way back in MS-DOS beginnings. IIRC, the old MS VisualFortran compiler
also, used stdcall convention by default, but did not use the @n stdcall
decoration, Now, MS has a popular language called VisualBasic, that like
Pascal, uses __stdcall convention (sans decoration of symbol names). So
if you want to use your gfortran dll in a VB app, the simplest thing to do is
build your dll's the MS way.  That is where -mrtd comes in. 
(And please do read the big caveat about using -mrtd in gcc.info.)

The @n stdcall suffix is an extern "C" language thing. (MS compiler
doesn't even use in C++, but G++ does.) To link against a stdcall
function exported from a DLL (undecorated as per win32api convention)
you need to map the the stdcall name expected by C to the undecorated
Pascal name exported from the DLL. This is normally done by the linker
when building a DLL import lib from a .def file. The GNU linker option to
accomplish this is "--kill-at".

Danny


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31073

Reply via email to