<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
> From: <A href="mailto:rv82@ya.ru">rv82@ya.ru</A> <BR> > To: <A href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</A> <BR> > Subject: Re: [M3devel] Building DLLs for Win32 (NT386MINGNU) <BR> > Date: Thu, 5 Mar 2009 07:44:16 +0300 <BR> > <BR> > And, Is it possible to use DLLs built with other languages? For example, <BR>
> may I import DLL built by C in Modula-3 program? <BR><BR>
Definitely..just perhaps not stuff built with Cygwin (nothing to do with Modula-3, interop with Cygwin is slightly difficult even for C code built with another compiler/runtime).<BR>
<BR>
Basically, you have to rewrite your headers in Modula-3.<BR>
Modula-3 "headers" are ".i3" files -- i for interface, 3 for Modula-3.<BR>
And either LoadLibrary/GetProcAddress, or have an import .lib.<BR>
In the Modula-3 you mark the functions with an "external" "pragma".<BR>
<BR>
Large example:<BR>
<A href="http://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/win32/WinBase.i3?rev=1.7;content-type=text%2Fplain">http://modula3.elegosoft.com/cgi-bin/cvsweb.cgi/cm3/m3-libs/m3core/src/win32/WinBase.i3?rev=1.7;content-type=text%2Fplain</A><BR>
<BR>
small example..<BR>
<BR>
There were some nice small examples in the Critical Mass product.<BR>I can't find them online.<BR>
Maybe...<BR>
<BR><A href="http://modula3.elegosoft.com/cm3/doc/index.html">http://modula3.elegosoft.com/cm3/doc/index.html</A><BR>
has a link "CM3 Examples" to <A href="http://modula3.elegosoft.com/cm3/doc/example/">http://modula3.elegosoft.com/cm3/doc/example/</A><BR>but it doesn't work.<BR>
<BR>
<BR>
I know this is kind of difficult to understand..but think about this..the Modula-3 compiler and runtime are written in Modula-3. They work. They read and write files, create threads, etc. -- they use the underlying system, which is composed of .dlls, which aren't written in Modula-3. Therefore, the answer to your question must be "yes". They call into the underlying system from Modula-3 using the same techniques as you would use. Of course, you also want to know how to do it, which this thought exercise does not immediately reveal -- you'd have to look at the compiler/runtime, find the calls to open files, etc., and trace them down. You would in fact eventually get to this WinBase.i3 file and its CreateFile declaration, but it takes searching through a few layers. Another thing you can do is run the compiler under a debugger and break on CreateFile (CreateFileA, CreateFileW) and look at the stack, and the file names on it. That can speed the search significantly. Oh, and WinBase.i3 wouldn't be on the stack, as the way it works, these declarations let other Modula-3 code call directly into the underlying system, without a "wrapper". (Well, lately I have been adding wrappers, for a good reason, but that is another matter.)<BR>
<BR>
<BR>
Um, why do you favor NT386MINGNU/mingw over NT386/Visual C++? There is a free "beer" download, the "Express Edition", which should work. Have you tried that? I know there are reasons but I'm curious to know what yours are.<BR>
<BR>
<BR>
<BR> - Jay<BR><BR></body>
</html>