[erlang-questions] Can't get a resource in a nif
Wed Jan 19 13:40:19 CET 2011
returns a struct fann *.
I've been working with erlang for too long so my C knowledge has totally
deteriorated so I might be missing something basic. I also feel that the
resource concept is a bit fuzzy so I might be doing it wrong. I figured that
the resource pointer that I allocated pointed to some memory where I could
in turn point the newly created network from fann_create_standard_array?
I fixed the tuple_array but I am still getting the same error.
I am compiling with gcc -shared -fpic -l fann -o fann_nif.so fann_nif.c -I
>From running erl:
Erlang R14B01 (erts-5.8.2) [source] [rq:1] [async-threads:0]
Eshell V5.8.2 (abort with ^G)
3> fann:train_on_file(A, "xor.data", 20, 3, 0.5).
** exception error: bad argument
in function fann:train_on_file/5
called as fann:train_on_file(<<>>,"xor.data",20,3,0.5)
On Wed, Jan 19, 2011 at 12:30 PM, Sverker Eriksson <
> Erik Axling wrote:
>> I'm trying to write a NIF for the Fast Artificial Neural Network library
>> that is written in C. But I'm running into a problem where I use a
>> to allocate a pointer for a network that I have created. When I try to get
>> that resource it fails for an unknown reason. I have used printfs to be
>> able to know where the error occurs. My NIF returns a badarg.
>> The C code is here: https://gist.github.com/785854
>> Thanks for any help.
>> /Erik Axling
> (Seems the dingo ate the new-lines in my first reply)
> After a second glance I see you use your 'tuple_array' wrongly.
> You should define it as
> const ERL_NIF_TERM * tuple_array;
> and then use &tuple_array as argument to enif_get_tuple(). It's an
> "out-argument" just like &tuple_size.
More information about the erlang-questions