Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pointers returned from dll function when called from rebol

Tags:

dll

rebol

rebol2

I am trying to ascertain weather I can use rebol for a few programming tasks. I have written a small program which loads an external library and calls a function which returns pointers in some of the arguments. When I run the program it crashes rebol.exe. I am hoping somebody can help me out. The dll function is as follows:

void xxx swe_utc_time_zone(int32 iyear, int32 imonth, int32 iday, 
int32 ihour, int32 imin, double dsec, double dtimezone, 
int32 *iyear_utc, int32 *imonth_utc, int32 *iday_utc, 
int32 *ihour_utc, int32 *imin_utc, double *dsec_utc)

and this is my small test program:

rebol []
astrology-lib: load/library %/c/sweph/bin/swedll32.dll
swe-utc-time-zone: make routine! [
   iyear [integer!]
   imonth [integer!]
   iday [integer!]
   ihour [integer!]
   iminute [integer!]
   dsec [decimal!]
   dtimezone [decimal!]
   iyear-utc [char*]
   imonth-utc [char*]
   iday-utc [char*]
   ihour-utc [char*]
   iminute-utc [char*]
   dsec-utc [char*]
] astrology-lib "_swe_utc_time_zone@60"
swe-utc-time-zone 2015 6 20 0 19 0 -4.5 none none none none none none

The program crashes on the last line where I attempt to call the function. The error message is "REBOL/View system has stopped working"

like image 313
user1897830 Avatar asked Oct 31 '22 01:10

user1897830


1 Answers

You have to provide memory with at least the same size as the pointer you want to get back from your call.

So instead of none you should use words initialized with something along the line of

iyear-utc: make struct! [
    point [integer!]
] none

Maybe these links will give you more help adress, conversions, more conversions

like image 57
sqlab Avatar answered Jan 04 '23 13:01

sqlab