/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

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