Re: Phix: cffi.e

new topic     » goto parent     » topic index » view thread      » older message
petelomax said...
andreasWagner said...

only for windows 32bit but it works

They are rare, but I've seen a couple of places where this bites, for instance libcurl.e has this:

 
    if xcurl_easy_setopt=NULL then 
        xcurl_easy_setopt = define_c_func(libcurl, "curl_easy_setopt", {C_PTR, C_INT, C_PTR}, C_INT) 
        if machine_bits()=32 then -- split a curl_off_t (64 bit int) into two 32-bit ints 
            xcurl_easy_setopt2 = define_c_func(libcurl, "curl_easy_setopt", {C_PTR, C_INT, C_PTR, C_PTR}, C_INT) 
        end if 
    end if 
    ... 
    if machine_bits()=32 and option>30000 then 
        atom paramhi = floor(param/#1_0000_0000) 
        param = remainder(param,#1_0000_0000) 
        res = c_func(xcurl_easy_setopt2, {curl, option, param, paramhi}) 
    else 
        res = c_func(xcurl_easy_setopt, {curl, option, param}) 
    end if 

It may be that you need to ram two floats into a 64-bit value the hard way, ie faff about with poke(atom_to_float32()) and peek8(), on 64-bit.

What I have found so far in raylib, these stumbling blocks are not rare. For 64bit I just gave up for the moment.
The following sentences are from the Phix documentation (define_c_func).

Currently, there is no way to pass a C structure by value or get a C structure as a return result. 
You can only pass a pointer to a structure and get a pointer to a structure as a result.  
I think I'll just wait until these features are possibly included in a Phix 2.0 version.

Until then I'll play around with raylib(phix) here:
https://github.com/andizk4kx/raylib-playground/tree/main

Thanks for your support and especially for Phix.

Andreas

new topic     » goto parent     » topic index » view thread      » older message

Search



Quick Links

User menu

Not signed in.

Misc Menu