Re: How to deal with C_POINTR?

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

>when define and call c_func often there are parameters passed by
>pointers, then how to send and get data if it is a c struct?

Let's say you have:

typedef struct
{
  int a,b;
} foo;

foo *bar(foo *grill)
{
  return grill;
}


Then you could do something like:

constant FOO_A=0, FOO_B=4, SIZEOF_FOO=8
constant grill = allocate(SIZEOF_FOO)

constant bar = define_c_func(blah,"bar",{C_POINTER},C_POINTER)

grill = c_func(bar,{grill})

? peek4s(grill+FOO_B)   -- print grill->b

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

Search



Quick Links

User menu

Not signed in.

Misc Menu