[Mono-devel-list] malloc and free on CLI

Jeyasankar Kottalam mono at jey.kottalam.net
Tue Jul 19 12:58:10 EDT 2005


>> Think of the following scenario: a library (say zlib) is compiled
>> to managed code (so we have zlib.dll).
>> Another existing C program that we want to compile to managed code
>> uses zlib (which means its sources include the zlib headers).
>> Now, the zlib headers do not contain any mapping attribute (and
>> IMHO they should stay as they are), so we need another way to tell
>> the C compiler how to map those calls.
>> I presume the C compiler generates a class with a lot of static
>> methods, one for each C function.
>> One easy way to specify the mapping outside of the header files
>> would be to tell the compiler "all the static methods of these
>> classes are managed C functions, and they have precedence over
>> their unmanaged dllimported ones".
>> Since the C namespace (for linking) is flat, this should work very
>> well.
>
> My current plan is to use the linker to automatically determine and
> resolve such
> cases by generating the appropriate P/Invoke declarations. This is on my TODO
> list for this week.
>

I meant: generating P/Invoke declarations for the native calls, and the
appropriate 'metadata references' for the managed functions. We can 
address the
issue of conflicting unmanaged and managed libraries by specifying 
precedence to
the linker, but typically that problem should not occur, since you probably
would not specify both the managed and unmanaged zlib libraries to the linker
when linking your application.

-Jey Kottalam





More information about the Mono-devel-list mailing list