File: short_example.m

package info (click to toggle)
mercury 0.9-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 18,488 kB
  • ctags: 9,800
  • sloc: objc: 146,680; ansic: 51,418; sh: 6,436; lisp: 1,567; cpp: 1,040; perl: 854; makefile: 450; asm: 232; awk: 203; exp: 32; fortran: 3; csh: 1
file content (22 lines) | stat: -rw-r--r-- 557 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
% This is a simple example of using the C interface to call the C function
% (or macro) puts().

% This source file is hereby placed in the public domain.  -fjh (the author).

:- module short_example.
:- interface.
:- import_module io.

:- pred main(io__state::di, io__state::uo) is det.

:- implementation.

:- pred puts(string::in, io__state::di, io__state::uo) is det.

:- pragma c_header_code("#include <stdio.h>").

:- pragma c_code(non_recursive, puts(S::in, Old_IO::di, New_IO::uo),
	"puts(S); New_IO = Old_IO; "
).

main --> puts("Hello, world\n").