[mercury-users] list of floats C interface problem

James Cussens jc at cs.york.ac.uk
Fri Jun 18 18:07:24 AEST 2010


Dear all,

The following program returns junk rather than the expected 3.0. If all 
the floats are changed to ints all is well. Can anyone help me 
understand what's going on? I'm using mercury-compiler-rotd-2010-04-17

James


:- module testlist.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module list.
:- import_module float.

main(!IO) :-
	test2([3.0,4.0],X),
	io.print(X,!IO).


:- pred test2(list(float)::in,float::out) is det.
:- pragma foreign_proc("C",
		       test2(Probs::in,Tot::out),
		       [will_not_call_mercury,promise_pure],
		       "
		       Tot = MR_list_head(Probs);
		       ").


-- 
James Cussens
York Centre for Complex Systems Analysis             jc at cs.york.ac.uk
Department of Biology (Area 17)               Tel  +44 (0)1904 328396
University of York                            Fax  +44 (0)1904 500159
PO Box 373, York YO10 5YW, UK            http://www.cs.york.ac.uk/~jc
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list