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

Home » Public Forums » archive » make_dll and call_external woes
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: make_dll and call_external woes [message #70567 is a reply to message #70469] Sun, 18 April 2010 16:33 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Apr 18, 6:02 pm, James <donje...@gmail.com> wrote:
> Hi everyone,
>
> I'm working on some code that's loop-heavy, so I'd like to do the
> loopy part with an external C program.  I'm using MAKE_DLL to compile
> and then CALL_EXTERNAL.  My system is Windows XP with the Microsoft
> Visual C++ Express compiler, running in 32-bit mode.
>
> I'm using very large data sets, so I would like to pass only pointers
> to my C function.  I wrote a little test program like this.  It takes
> all the arguments that my actual program needs, but it just alters one
> value to see if anything happens:
>
> void raycast(unsigned char * image, unsigned char * angles, unsigned
> char * magnitudes, int * dims)
> {
>         angles[0] = 100;
>
> }
>
> I compile this using MAKE_DLL successfully.  I've tested if the code
> is getting called by adding an IDL_message(), and it works - the
> message prints out on the IDL console.  Unfortunately, the above code
> does not work.  I call it in IDL like this:
>
> [stack is a preexisting 3-dimensional byte array]
>    dims = fix(size(*stack, /dimensions))
>    angles = ptr_new(bytarr(dims))
>    magnitudes = ptr_new(bytarr(dims))
>    dimsptr = ptr_new(long(reverse(dims)))
>    call_external (dir + "raycast.dll", "raycast", $
>             stack, angles, magnitudes, dimsptr, /cdecl, /all_value)
>
> but when I check the value of (*angles)[0] afterward, it's still 0.  I
> also check with max(*angles) and it's 0 as well.  Why is my C program
> not changing anything in the array?  I get the same problem whether I
> include the /ALL_VALUE keyword or not.
>
> Many thanks to anyone who can make sense of this issue!

From the documentation:
"/CALL_VALUE. Set this keyword to indicate that all parameters are
passed by value."

Parameters passed by value can be changed by the called routine, but
changes do not appear to the caller.

Craig
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: READS: End of input data encountered
Next Topic: Problem using the method List->ToArray()

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

Current Time: Thu Oct 09 21:16:29 PDT 2025

Total time taken to generate the page: 0.64150 seconds