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

Home » Public Forums » archive » 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
CALL_EXTERNAL [message #33883] Tue, 04 February 2003 22:14
Thomas Gutzler is currently offline  Thomas Gutzler
Messages: 44
Registered: November 2002
Member
Hi again,

please correct me if I'm wrong.

CALL_EXTERNAL
- needs the /CDECL keyword to call a dll built by Borland C++ Compiler
with: extern "C" __declspec(dllexport)
It works with and without /CDECL for me
- can have values and references (default) as arguments but cannot
RETURN a pointer. Just a scalar variable with the value of an address
- cannot have a NullPointer as argument and receive a Pointer to a
variable/array (see below)

What I'm trying to do is:

C function:
int test(int argc, void* argv[])
{
if(argc != 2) return 0;
IDL_UINT *size = (IDL_UINT *) argv[0];
int *array = (int *) argv[1];
array = new int[*size];
for (int i = 0; i < *size; i++) array[i] = i;
return 1;
}

IDL:
IDL> array = PTR_NEW()
IDL> Result = CALL_EXTERNAL('mydll.dll', '_test', 10, array, /CDECL)
IDL> print, array
should be
0 1 2 3 4 5 6 7 8 9
but array is still a NullPointer

If I leave the line
array = new int[*size];
I have to initialize with array=intarr(10) and the returned array is:
0 0 1 0 2 0 3 0 4 0

This is not what I expected (funny values! maybe type-conversion helps?)
and not what I want. I want to receive a pointer to an array, because
IDL doesn't know the size of the array being returned (Yes, I could
allocate a 1000000x1 array and resize it).

Is this possible ?

Tom
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: PNGs with alpha channel?
Next Topic: Re: OPENW and environment variables in IDL 5.5

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

Current Time: Wed Oct 08 14:52:46 PDT 2025

Total time taken to generate the page: 0.00438 seconds