[clean-list] Help in clean and c, create dll

John van Groningen johnvg at cs.ru.nl
Fri Jan 19 12:31:57 MET 2007


Fabricio Leonard wrote:
>Olá, I am writing to know if somebody possesss some material on the creation of DLL in clean and the call for programs in c \ c++. I obtained to make only with type of entire parameters, I need the other types (double, to char, string, Array and etc).
>regards,

Clean 2.2 only supports passing arguments and results of type Int in functions exported using foreign export.

I have added support for passing types Real and String/{#Char} using foreign
export. You can download this new compiler at:

http://clean.cs.ru.nl/download/Clean22/windows/Clean_2.2_extended_foreign_export.zip

To use this compiler copy the 3 files in the zip file into the Tools/Clean System directory of Clean 2.2 (overwriting the old files with the new version).

Real's are passed to/from c as type double. String's are passed as
CleanString, as defined in Tools/htoclean/Clean, so as a pointer
to an integer representing the length in characters of the string,
followed by the characters (no extra '\0' at the end).

If a string is passed from c to Clean, a copy is made in the Clean heap,
and this copy is used. If a string is passed from Clean to c, the c
function is passed a pointer to a string inside Clean's heap. This pointer
should not be used any more after the c function returns, because the
garbage collector may move or deallocate the string. The c programmer
is responsible for releasing any memory allocated for these strings
in c, because the foreign export interface does not call functions that
free memory, like free or LocalFree.

You can pass characters by converting them to/from integers using
toChar,fromChar,toInt or fromInt and pass the integers.

If you need to pass values of type {#Int} or {#Real} using foreign export,
let me know and I will add supports for these types.

Kind regards,

John van Groningen




More information about the clean-list mailing list