[m-users.] foreign_type confusion on how to do it across modules...

emacstheviking objitsu at gmail.com
Sun Jul 14 08:53:28 AEST 2019


In my sdl2.m module I have this code



*    % SDL_Rect:- type sdl_rect.:- pragma foreign_type("C", sdl_rect,
"SDL_Rect", [can_pass_as_mercury_type]).*

The SDL_Rect structure is perfect enough and I don't want to define
something like:

*:- type sdl_rect ---> sdl_rect(x::int, y::int, w::int, h::int).*

all over the place. The compiler seems to be happy with the fact that when
I type "sdl_rect" I will get "SDL_Rect" but in my test module I just can't
figure out how to create an instance of it to actually pass atound!

*  sdl_renderfillrect(Rnd, sdl_rect(0, 50, 200, 100), !IO),*

So...given I have declared an abstract type "sdl_rect" which is SDL_Rect
under the hood....I can't believe I am even asking this as I have a
horrible feeling the answer is so obvious......whataver....better to ask!

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20190713/007fa7a5/attachment.html>


More information about the users mailing list