PageRenderTime 3ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/external/C/example3.e

http://github.com/tybor/Liberty
Specman e | 37 lines | 22 code | 5 blank | 10 comment | 0 complexity | e7c6563f83a0f29407891402709d28ae MD5 | raw file
 1class EXAMPLE3
 2   --
 3   -- How to use C macro from Eiffel.
 4   --
 5   -- To compile this file:
 6   --
 7   --       compile example3
 8   --
 9
10create {ANY}
11   make
12
13feature {ANY}
14   make
15      local
16         v: INTEGER; output_ptr: POINTER
17      do
18         -- Calling the C `sum' macro from Eiffel:
19         v := sum(1, 2)
20         io.put_string("sum(1,2)=" + v.to_string + "%N")
21         -- Calling standard C `stdin' macro from Eiffel:
22         output_ptr := stdout
23      end
24
25feature {}
26   sum (a, b: INTEGER): INTEGER
27         -- (Corresponding C function defined in c_glue2.c)
28      external "[
29                 C macro use "c_glue3.h"
30               ]"
31      end
32
33   stdout: POINTER
34      external "C macro use <stdio.h>"
35      end
36
37end -- class EXAMPLE3