[m-users.] Calling type constructors from C

emacstheviking objitsu at gmail.com
Wed Jul 10 18:46:31 AEST 2019


Any clues in the documentation as to where I can find out how to do this?
I've looked (and failed) to figure out how to call "maybe(T)" from C,
basically I have the result of calling a C function that reutns NULL or a
window pointer:

   SDL_WIndow *w = SDL_CreateWindow(...);

and I want the pred to return maybe(sdl_window) where so in my main code I
can switch on the result blah blah

sdl_creatwindow(..., MW, ..., !IO),
(
    MW = yes(Wnd),
    % start my app
;
    MW = no,
    % fail path
),


:- type sdl_window.
:- pragma foreign_type("C", sdl_window, "SDL_Window *",
[can_pass_as_mercury_type]).

It's just knowing what the "way" is?!?!

Thanks,
Sean.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20190710/d376370b/attachment.html>


More information about the users mailing list