List Info

Thread: "ocaml_beginners"::[] a question about how C uses OCaml functions




"ocaml_beginners"::[] a question about how C uses OCaml functions
user name
2006-12-24 13:51:06

On Sun, Dec 24, 2006 at 02:35:02AM -0000, mqznudt wrote:
> I want to use the module cfg.ml in CIL,call the functions in that
> module in C program.For example ,for a function cfgFun according to
> the method,first step:
>; let rec cfgFun(fd:fundec):int=
> ....................
> ....................
> let_=Callback.register "cfgFun" cfgFun
> second step:call this function from C
> ....................
> ....................
> int cfgFun(?????)
> {
> ....................
> ....................
> }
> the problem is what to use as a parameter in the parentheses.

I'm a bit confused here. Did you call caml_named_value to get the
value of the named callback? Did you try passing this to
caml_callback? If in doubt, read section 18.7.2 of the manual
carefully:

http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html

Rich.

--
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Internet Marketing and AdWords courses - http://merjis.com/courses - NEW!
Merjis blog - http://blog.merjis.com - NEW!

__._,_.___
.

__,_._,___
"ocaml_beginners"::[] a question about how C uses OCaml functions
user name
2006-12-25 11:40:52

--- In ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com, Richard Jones <rich...>
wrote:
>
> On Sun, Dec 24, 2006 at 02:35:02AM -0000, mqznudt wrote:
&gt; > I want to use the module cfg.ml in CIL,call the functions in
that
> > module in C program.For example ,for a function cfgFun according
to
> > the method,first step:
>; > let rec cfgFun(fd:fundec):int=
> > ....................
> > ....................
> > let_=Callback.register "cfgFun" cfgFun
&gt; > second step:call this function from C
> > ....................
> > ....................
> > int cfgFun(?????)
> > {
> > ....................
> > ....................
> > }
> > the problem is what to use as a parameter in the parentheses.
>
> I'm a bit confused here. Did you call caml_named_value to get the
> value of the named callback? Did you try passing this to
> caml_callback? If in doubt, read section 18.7.2 of the manual
&gt; carefully:
>
> http://caml.inria.fr/pub/docs/manual-ocaml/manual032.html
>
> Rich.
>;
> --
> Richard Jones, CTO Merjis Ltd.
> Merjis - web marketing and technology - http://merjis.com
> Internet Marketing and AdWords courses -
http://merjis.com/courses - NEW!
> Merjis blog - http://blog.merjis.com - NEW!
>First of all,thank you for your answer,perhaps i didn't say my
problem clearly and forgive me

the most difficult I meet is that some data structures in OCaml
can't be expressed in C ,for example "fd:fundec" I have mentioned
above,is a union of some complex data structures,I can't use modules
including functions whose parameters like this!
I will read what you gave me again,thanks and MERRY CHIRASTMAS to
everyone

Meng Qingzhi

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )