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

emacstheviking objitsu at gmail.com
Tue Jun 25 20:44:33 AEST 2019


Solved!
I had the OLD version of SDL under /usr/include/SDL and the new SDL2 under
/usr/include/SDL2  !!! I've sincve totally obliterated the old version!
I guess it's Sherlock Holmes again isn't it, "no matter how imporable, must
be the truth"...and the compiler told the truth I was too dumb to see it!

I also think I need to appreciate more that functions ARE just predicates
more!


On Tue, 25 Jun 2019 at 11:34, Julien Fischer <jfischer at opturion.com> wrote:

>
> Hi Sean,
>
> On Tue, 25 Jun 2019, emacstheviking wrote:
>
> > 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
>
> The error is coming from the C compiler when it attempts to compile the
> generated C code.  (The Mercury compiler emits #file and #line directives
> so that C compiler errors are mapped backed to their location in the
> original Mercury source file.)
>
> > 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:
>
> Declarations from foreign_decl pragmas and alike are placed in a Mercury
> header file (.mh) and #included in generated .c files.  Look for the file
> ffi.mh.  The contents of the foreign_decl pragmas should be in that.
>
> >      mmc -v -L /usr/lib/x86_64-linux-gnu/libSDL2.so -lSDL2 --make ffi
>
> It looks as though the C compiler can't see the SDL header files.
> You can use the Mercury compiler's --c-include-directory option to pass
> their location through to the C compiler.
>
> Julien.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20190625/cc717dad/attachment.html>


More information about the users mailing list