[m-users.] 64 bit subtraction, compiler sees 'int'

"Sean Charles (emacstheviking)" <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <[email protected]>
Hi,

I am getting this error:

agame.m:158: In clause for predicate `game_loop'/8:
agame.m:158:   in unification of variable `Diff'
agame.m:158:   and term `(Now - Then)':
agame.m:158:   type error in arguments of functor `-'/2.
agame.m:158:   Argument 1 (Now) has type `int64',
agame.m:158:   expected type was `int'.
agame.m:158:   Argument 2 (Then) has type `int64',
agame.m:158:   expected type was `int'.
** Error making `Mercury/cs/agame.c'.

I have this predicate, an FFI, to get the current 64 bit tick counter:

:- pred sdl_getticks64(int64::out, io::di, io::uo) is det.

:- pragma foreign_proc("C", sdl_getticks64(Ticks::out, _IO0::di, _IO::uo),
    [promise_pure,will_not_call_mercury,does_not_affect_liveness],
"
    Ticks = SDL_GetTicks64();
").

I assign it like this in the setup code

    sdl_getticks64(Now, !IO),
    game_loop(Window, Renderer, Now, Now, !GameState, !IO),


ad then in the game loop I calculate the difference but I don't see how I've failed to convey to the compiler the use of 64 bits!

        :- pred game_loop(sdl_window::in, sdl_renderer::in, int64::in, int64::in,
            game_state::in, game_state::out, io::di, io::uo) is det.

    157: game_loop(W, R, Now, Then, !State, !IO) :-
==> 158:    Diff = (Now-Then),
            io.format("Now: %li, Then: %li, Diff: %li\n",
                [ i64(Now), i64(Then), i64(Diff) ], !IO),


I can't see where it thinks the expected type was 'int'. Is there a different library I should use, I looked but couldn't really find anything in 'int' or 'math'.

Thanks,
Sean.

_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.