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

Home » Public Forums » archive » Re: Structures and Call_External
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Structures and Call_External [message #1863] Wed, 23 March 1994 10:21
rarback is currently offline  rarback
Messages: 15
Registered: October 1992
Junior Member
In a previous article, rivers@bnlux1.bnl.gov (Mark Rivers) writes:
> Passing structures to/from IDL with CALL_EXTERNAL is officially
> unsupported. HOWEVER, it does presently work. What is passed is the
> address of the first element in the structure. So you can define an IDL
> structure which is the same as your C structure, pass its address in
> CALL_EXTERNAL, and use memcpy to copy the data from the C structure to the
> IDL structure. The only caveat at present is that your IDL structure cannot
> contain strings, because these are passed by descriptor in the
> structure. You can use BYTE arrays in place of strings. Other than
> strings the IDL structures allocate memory sequentially for each element
> just as C does. On some platforms there may be data alignment issues
> which you will have to determine empirically.

It appears that IDL structures share the alignment of the "native" machine's
C compiler. In particular, in porting some (inherently nonportable) IDL code
from OpenVMS/VAX to OpenVMS/AXP, the structure alignment went from completely
unpadded (VAX C) to strict member alignment (DEC C).

--Harvey
----
Harvey Rarback phone: (516) 282-5626
CARS fax: (516) 282-7078
Building 815 Internet: rarback@bnlx26.nsls.bnl.gov
Brookhaven National Lab ESnet/SPAN: BNLX26::RARBACK
Upton, NY 11973 BITNET: RARBACK@BNL
Re: Structures and Call_External [message #1872 is a reply to message #1863] Tue, 22 March 1994 20:29 Go to previous message
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
In article <Kile_Baker-180394122621@bakers-mac.jhuapl.edu> Kile_Baker@jhuapl.edu (Kile Baker) writes:
> I have some complicated structures that are used with C routines and I
> would
> like to pass this data into an equivalent structure in IDL. I know I can
> do it by passing the original structure in as a byte array and then
> uppacking the byte array in IDL, but that is a slow process. Is there any
> way of passing
> the structure directly in to an IDL structure?
>

Passing structures to/from IDL with CALL_EXTERNAL is officially
unsupported. HOWEVER, it does presently work. What is passed is the
address of the first element in the structure. So you can define an IDL
structure which is the same as your C structure, pass its address in
CALL_EXTERNAL, and use memcpy to copy the data from the C structure to the
IDL structure. The only caveat at present is that your IDL structure cannot
contain strings, because these are passed by descriptor in the
structure. You can use BYTE arrays in place of strings. Other than
strings the IDL structures allocate memory sequentially for each element
just as C does. On some platforms there may be data alignment issues
which you will have to determine empirically.

This is not guaranteed to continue to work, since RSI may change the
way structures are stored internally. Such a change could be made to
allow array sizes to change inside a structure.

I am routinely passing structures, and arrays of structures, with
CALL_EXTERNAL on IDL under VAX/VMS. I am quite sure it will work on
other platforms as well. Be aware that it could break in a future
release...


--
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: map projection polygon problem
Next Topic: Re: map projection polygon problem

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

Current Time: Sat Oct 11 12:51:40 PDT 2025

Total time taken to generate the page: 1.43714 seconds