[m-users.] FFI C Include files not appearing

emacstheviking objitsu at gmail.com
Tue Jun 25 20:03:53 AEST 2019


Hi,
I have these two lines of code...

:- pragma foreign_decl("C", "#include <SDL/SDL.h>").
:- pragma foreign_decl("C", "#include <SDL/SDL_version.h>").

at the top of my module in the implementation section and this code too:
:- func sdl_up = int.
:- pragma foreign_proc("C",
                       sdl_up = (Result::out),
                       [ will_not_call_mercury
                       , not_thread_safe
                       , promise_pure
                       ],
                       "Result = SDL_Init(SDL_INIT_EVERYTHING);").


:- func sdl_revision = string.
:- pragma foreign_proc("C",
                       sdl_revision = (Version::out),
                       [ will_not_call_mercury
                       , not_thread_safe
                       , promise_pure
                       ],
                       "Version = (MR_String*)SDL_GetRevision();").

The call to SDL_Init() seems to work but the compiler produces an error
message saying that it cannot finf SDL_GetRevision()

ffi.m: In function ‘ffi__sdl_revision_0_f_0’:
ffi.m:37:23: warning: implicit declaration of function ‘SDL_GetRevision’;
did you mean ‘SDL_GetCursor’? [-Wimplicit-function-declaration]
                        "Version = (MR_String*)SDL_GetRevision();").
                       ^~~~~~~~~~~~~~~
                       SDL_GetCursor

When I look at the Mercury/cs/ffi.c file i can not see any of my includes
and so I wonder how it worked at alL! the command line I used was:

     mmc -v -L /usr/lib/x86_64-linux-gnu/libSDL2.so -lSDL2 --make ffi

for a main of:

main(!IO) :-
        format("WTAF? %d, %s\n",
               [ i(sdl_up)
               , s(sdl_revision)
               ],
               !IO).

At this early stage of my exposure to mercury(!) < 10 hours, it all feels
like an uphill struggle as i can't see what I have done wrong.

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


More information about the users mailing list