[Mono-list] Re: DllImport and extern declarations for values

Thomas Sondergaard thomas@thomassondergaard.com
Tue, 30 Sep 2003 14:16:19 +0200


> I would suggest that you leave out the pathnames in the DllImport
> statements, unless you want to guarantee that all users (on all
> platforms!) will have it in the same location.... :-)

Heheh, no problem. This is just my prototype for playing around with
P/Invoke.

> You can't DllImport a variable.  Primarily because the PE file format
> doesn't support exporting variables (IIRC).

Hm, okay. I can work around that, I just didn't want to work around
something just because I didn't know how to do it TheRightWay.

> Though that might be overkill.  Yes, you should use a utility program.
> It'll probably be easiest to just custom write your own in Ruby.  It
> should be easy enough to create a regex that will grab the variable
> name, attach a suffix, use that for a function, and implement it.

It would be fairly easy to write a ruby script that parses ruby.h and
creates a C# wrapper, except the function declarations don't have parameters
names, so I'd have to live with names like a1, a2, etc.

> IJW is basically an implicit P/Invoke.  It uses the same runtime
> mechanism to call native functions.

This whitepaper by CompuWare seems to suggest otherwise:
http://teched2003downloads.mymsevents.com/compuware/interop.pdf. Mostly
because of the more advanced marshalling support with P/Invoke.

> MCS uses System.Reflection.Emit, and a couple enhancements needed to be
> made so that all of C# could be easily implemented using S.R.E.

Great :-)

Tom