24 lines
556 B
Plaintext
24 lines
556 B
Plaintext
:- module test_ffi.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
% The actual FFI code begins here.
|
|
:- pragma foreign_decl("C", "#include <string.h>").
|
|
|
|
:- func strdup(string::in) = (string::out) is det.
|
|
:- pragma foreign_proc("C", strdup(S::in) = (SD::out),
|
|
[will_not_call_mercury, not_thread_safe, promise_pure],
|
|
"SD = strdup(S);").
|
|
% The actual FFI code ends here.
|
|
|
|
main(!IO) :-
|
|
io.write_string(strdup("Hello, worlds!\n"), !IO).
|
|
|
|
:- end_module test_ffi.
|