Mail Archives: cygwin/2001/05/24/15:22:05
Ben Miller wrote:
>Hi,I have a function declared like this:
>extern "C" __declspec(dllexport) void __stdcall foo(){}
>When I build this into a DLL using the Visual C++ compiler (cl.exe),
>the exported name is:_foo AT 0
>but when I build it using the GNU C++ compiler (g++), the exportedname
is:foo AT 0
>Which one is correct? I have read that the stdcall convention should
>prepend an underscore to exported names - should the extern "C"
>qualifier remove it?Regards,Ben.
Use the -mrtd flags to make the stdcall calling convention the default
calling convention in your function calls, clean out __declspec(dllexport)
and stdcall from your C code, and then edit the line which references foo in
the def file. The dll should create line like
foo @ XX;
Where XX is some postive integer, which corresponds to foos place in the
array of exported functions. Change the line to look like:
_foo AT 0 = foo @ XX;
Alternatively you can leave you C code unchanged and the line created by the
dll tool should look like:
foo AT 0 @ XX;
Edit this to:
_foo AT 0 = foo AT 0 @ XX;
Hopefully this makes it to the mailing list and I get some feedback.
I am going to test this on my own code, and create a utility to automate
this process if it works resonably well. I have some large libraries that I
export to Splus and Excel, which all take the leading underscore.
The next problem you will likely face is debugging your dll's with GDB. You
need to insert the following function into your dll:
declspec(dllexport) void callbreak() {
__asm__( "int3");
}
Change to exces/Splus/whatever program's home directory. From Bash:
cd BIGPROGRAMHOME
run the program from gdb:
gdb BIGPROGRAM
(gdb) run
This should set up a process where excel/whatever runs just like normal. GDB
imposes very little overhead compared to other debuggers. Call the function
callbreak from excel/whatever and shift-tab back to your bash window. You
should see the gdb prompt
(gdb)
You can now place whatever breakpoints in your code that you need.
Let me know how this works. Please respond to me personally, because I don't
subscribe to the list, I just search the archives.
Best Regards,
Clark Sims
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -