comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Can't pass data with CALL_EXTERNAL to C function
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Can't pass data with CALL_EXTERNAL to C function [message #60842 is a reply to message #60835] Fri, 20 June 2008 04:18 Go to previous messageGo to previous message
Allan Whiteford is currently offline  Allan Whiteford
Messages: 117
Registered: June 2006
Senior Member
Dan wrote:
> Hi everyone,
>
> I am having problems sending data to my C function through
> CALL_EXTERNAL. Specifically, I send the data, but it seems as if all
> the variables passed to the C function are suddenly 0 (maybe
> uninitialized). I have posted my test code below. Please take a
> look, any help would be greatly appreciated. It is also probably
> worth mentioning that when I return something from the function (like
> return 2;) or something like that, the IDL value will be 2 (i.e.
> values are returned correctly, so I know the function is at least
> running to completion).
>
> ----- CODE -----

<snip>

Dan,

It's hard to see/test exactly what you're doing as some of your lines
have been truncated (unfortunately the important line including
call_external).

However, the following is a short example of something which goes along
the lines of what you're doing and works ok for me:

passref.pro
-----------

pro passref
a=fltarr(100,100)
b=fltarr(200,200)

a[17,23]=3.14
b[52,79]=2.72

junk=call_external('passref.so','passref',a,b)

print,a[12,54]
end

passref.c
---------

#include <stdio.h>
#include "idl_export.h"

void do_work(float *a,float *b)
{
a[12+54*100]=1.62;
printf("%f\n",a[17+23*100]);
printf("%f\n",b[52+79*200]);
}

IDL_VPTR passref(int argc, IDL_VPTR argv[])
{
do_work((float *) argv[0],(float *) argv[1]);
}

Compilation
-----------

gcc -I/usr/local/rsi/idl/external/include \
-shared passref.c -o passref.so

I hope this helps. If you can repost your original example without the
lines being cut off then probably someone can point out the exact part
you'd need to change to get it working. In particular, the keywords
you're giving to call_external are probably important.

Thanks,

Allan
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Implementation of G Statistic in IDL
Next Topic: Multidimensional arrays and CALL_EXTERNAL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 11:56:41 PDT 2025

Total time taken to generate the page: 1.84155 seconds