Re: passing pointers to CALL_EXTERNAL [message #11311] |
Wed, 25 March 1998 00:00 |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
hdsfkj wrote:
>
> Hi Again,
>
> 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...
>
> Donald Green
> dfg@ai.mit.edu
Unless things have changed drastically the last time I looked at
the docs for CALL_EXTERNAL, you must define the array before
passing it to the C routine. An array in IDL is much more complex
than an array in C; I suppose this would be possible if you
knew a lot about the internal structure of variables in IDL, but
I would just create the array first!
Dave
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|
Re: passing pointers to CALL_EXTERNAL [message #11319 is a reply to message #11311] |
Tue, 24 March 1998 00:00  |
hdsfkj
Messages: 12 Registered: March 1998
|
Junior Member |
|
|
My limitation is that my dll is itself built by linking in functions provided
by a digital
camera company. Their image acquisition function allocates the memory (up to
2 Meg per image) and returns a pointer to it. Copying 2 million bytes is
going to
cost some time. Oh well, I guess I'll get my system working using the copying
method
and then learn the LINK_IMAGE interface at my leisure (i.e. probably never).
Thanks
for the replies everyone.
Donald.
David Fanning wrote:
> 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
|
|
|
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/
|
|
|