delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/05/24/15:22:05

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <001d01c0e483$841a2ad0$6982c039@3hi25.flashcom.com>
Reply-To: "Clark Sims" <csims AT templartrading DOT com>
From: "Clark Sims" <csims AT templartrading DOT com>
To: <Cygwin AT sources DOT redhat DOT com>
Cc: <Ben DOT Miller AT Mercia DOT com>
Subject: RE: Leading underscore in export names.
Date: Thu, 24 May 2001 13:58:05 -0500
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019