Re: passing pointers to CALL_EXTERNAL [message #11322 is a reply to message #11319] |
Tue, 24 March 1998 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Donald Green (dfg@ai.mit.edu) writes:
> Is there a way to return a pointer to an array of bytes from
> CALL_EXTERNAL? My C routine
> creates the array and fills it with values. I would like to just pass a
> pointer to the array back to
> IDL. I found an old post with dejanews that suggests it isn't possible.
> I'm trying to avoid the
> performance cost that goes with creating an array in IDL, passing a
> reference to it to the C routine, and copying the previously created C
> array to the IDL array. Thanks for any help...
>
Don't do this. You are headed for ruin. :-)
Call_External is a *simplified* interface to your C program.
As such it has limitations. One of them is that you MUST
create the arrays on the IDL side, even if you intend to
fill them on the C side. I doubt there is much "performance
cost", especially when you compare it to the "programming
cost", which in this case will be extremely high.
The explanation for why this limitation exists is too
long to go into here. If you think you really want to
become an IDL developer and write all your good code
in C, learn and use LinkImage as opposed to Call_External.
It offers all the bells and whistles and allows you
to do pretty much anything in you C program (within
certain minor limitations).
Cheers,
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|