best practice for calling C from Erlang

Joe Armstrong erlang@REDACTED
Mon Dec 13 14:37:20 CET 2010


What is "best practice for calling C from Erlang"

I have a C library I want to call from Erlang - nothing complicated.
Mostly the C functions are called with simple types, integers, strings etc.
and the return value is uninteresting. In the case where the return value is
interesting I mostly require an opaque return value - ie all I might
ever want to do
is re-use it in a subsequent call to a different C routine, so the actual return
value need never cross the C/Erlang boundary, but could be passed back
and forth
as a reference.

What is the best (and easiest) way to call this from Erlang.
Is there any program that takes a file containing C type declarations
(either in ANSI C, or as a erlang terms) and automatically builds
the C and Erlang sides of the interface?

The problem here is not the complexity of an individual
call, but the fact there are a large number of simple and rather
boring functions than must be called.

I know all about the ports
interface linked-in drivers etc. My question is more to do with
the automatic generation of an interface from some kind of specification.

/Joe


More information about the erlang-questions mailing list