Re: LINKIMAGE problem (beginner) [message #11112] |
Thu, 12 March 1998 00:00  |
rivers
Messages: 228 Registered: March 1991
|
Senior Member |
|
|
In article <35016939.EFC1ED89@gmx.net>, Reinhold Schaaf <Kakadu42@gmx.net> writes:
>
> --------------352DBFD156070D302A7B8B9C
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> Hi there,
>
> I want an IDL program call C subroutines. Since the CALL_EXTERNAL
> mechanism seems to provide no possiblities for typechecking (?) I want
> to use LINKIMAGE, where typechecking can (and must) be done. Everything
> is pretty nasty (I really don't like pointers on pointers on pointers
> ...), but anyway.
While it is true that CALL_EXTERNAL does not provide typechecking, I don't
think this is really a problem. Every function which you call via
CALL_EXTERNAL should be called through an IDL "wrapper" routine. That wrapper
routine, and ONLY THAT WRAPPER ROUTINE, is what does the CALL_EXTERNAL to your
C code. The wrapper routine converts all arguments passed to it to the correct
data type for the C function. Example:
pro my_test, input, output
; Assume your C code wants its input as a 32 bit int and returns a single
; precision float. The following code will ensure that input is converted to
; long (if required) and that the output is a float.
output = 0.0
status = call_external('my_lib', 'my_func', long(input), output)
end
____________________________________________________________
Mark Rivers (773) 702-2279 (office)
CARS (773) 702-9951 (secretary)
Univ. of Chicago (773) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars.uchicago.edu (e-mail)
or:
Argonne National Laboratory (630) 252-0422 (office)
Building 434A (630) 252-0405 (lab)
9700 South Cass Avenue (630) 252-1713 (beamline)
Argonne, IL 60439 (630) 252-0443 (FAX)
|
|
|