Just a small caveat/warning.

Interfaces across DLL boundaries are not type safe. 
You have to get the type right for both the caller and callee.
This might get fixed later, it is not easy: we'd love to use C++
typesafe linkage but that means predicting mangled names.
We could also generate our own. In both cases there's a serious
problem that the names used in the caller C++ and the DLL C++
are actually distinct (because they involve different sequence numbers
generated by the compiler in two separate compilations).

There is a trick to getting the types right.

When you call into a DLL you're calling a C function generated by "export".
This function is given a type like:

        export fun f of ( int * int ) as "f";

The type of this function is

        ret f (int, int);

which is 

        int * int --> ret

in Felix. However you can NOT call this function with the type
indicated here:

  f = Dynlink::func1[ret, int * int] (linst, "f");

All hell will break lose! You have to call it like this:

  f = Dynlink::func2[ret, int, int] (linst, "f");

i.e.  with two arguments, NOT with a single tuple argument.

It is certainly possible to pass tuples to C functions, but lacking
a "tuple of one type" there is no way to do this unless it is
one of several arguments: you can pass

        int * ( int * int )

and the second argument is a tuple. You cannot pass a tuple to a C function
with a single argument, since Felix uses a "trick" to decode top level products 
into
separate arguments (and there's no way to make a one argument tuple).

I fell into this trap. Be warned!

[Note: For ordinary C binding you CAN do it, there's a special code $t for 
passing
all the arguments as a single tuple.]

--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to