[erlang-questions] Accessing A Binary as an Array of Floats/Doubles Within a NIF

Steve Vinoski <>
Mon Jun 20 21:46:45 CEST 2016


On Mon, Jun 20, 2016 at 3:04 PM, John Duffy <> wrote:

> Hi
>
> I'm using FreeBSD 10.3 & Erlang 18.3 and I'm trying to get to grips with
> passing a binary of floats to a NIF for further processing as as array of C
> doubles.
>
> My simple NIF module compiles and I can access my "my_nif_1" function from
> the erlang shell. I can access the 'size' structure member but I can't
> figure out how to access the 'data' structure member as a C array. I
> understand that 'data' is a block of memory of UINT bytes but I can't
> figure out how to "cast" this to a C array within the NIF.
>

This doesn't answer your casting question, but is there a reason you're
using a binary and not a resource? See the "Resource Objects" section under
http://erlang.org/doc/man/erl_nif.html .

--steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160620/58584c77/attachment.html>


More information about the erlang-questions mailing list