[m-dev.] bugs?
Peter Schachte
schachte at cs.mu.OZ.AU
Tue Feb 3 15:09:57 AEDT 2004
Firstly, there are several small typos in the reference manual section
on "Using C pointers". I'm attaching a corrected version of that
code.
Secondly, when I try to compile that code, I get several warnings from
the C compiler about missing int<->pointer casts:
mudla% mmake pointer_example.o 14:57
mmc --compile-to-c --grade asm_fast.gc pointer_example >
pointer_example.err 2>&1
mgnuc --grade asm_fast.gc -- -c pointer_example.c -o pointer_example.o
pointer_example.m: In function `pointer_example_module0':
pointer_example.m:27: warning: assignment makes integer from pointer
without a cast
pointer_example.m: In function `pointer_example_module1':
pointer_example.m:31: warning: passing arg 2 of `perform_calculation'
makes pointer from integer without a cast
pointer_example.m:31: warning: assignment makes integer from pointer
without a cast
rm pointer_example.c
Any idea what the problem could be, or how to fix it? I'm using gcc
3.3.2 (Debian). I get similar messages for any foreign interface code
I compile.
Thanks for any help you can give.
--
Peter Schachte The trouble with the rat race is that even if you
schachte at cs.mu.OZ.AU win, you're still a rat.
www.cs.mu.oz.au/~schachte/ -- Lily Tomlin
Phone: +61 3 8344 1338
-------------- next part --------------
:- module pointer_example.
:- interface.
:- type complicated_c_structure.
% Initialise the abstract C structure that we pass around in Mercury.
:- pred initialise_complicated_structure(complicated_c_structure::uo) is det.
% Perform a calculation on the C structure.
:- pred do_calculation(int::in, complicated_c_structure::di,
complicated_c_structure::uo) is det.
:- implementation.
% Our C structure is implemented as a c_pointer.
:- type complicated_c_structure --->
complicated_c_structure(c_pointer).
:- pragma c_header_code("
extern struct foo *init_struct(void);
extern struct foo *perform_calculation(int, struct foo *);
").
:- pragma c_code(initialise_complicated_structure(Structure::uo),
[may_call_mercury],
"Structure = init_struct();").
:- pragma c_code(do_calculation(Value::in, Structure0::di, Structure::uo),
[may_call_mercury],
"Structure = perform_calculation(Value, Structure0);").
More information about the developers
mailing list