Creating an Eiffel wrapper for The GNU Multiple Precision Arithmetic Library (GMP)

Installing CIL (if not yet done):
git clone git://; cd cil
export PATH=$PATH:`pwd`/bin

1. Compiling the library (business as usual)

tar xfj gmp-5.0.5.tar.bz2; cd gmp-5.0.5

2. CIL preprocessing

  1. Creating the C file:
    You have to create a C file that includes all necessary library header files; for GMP this is only gmp.h.
    [GMP specific] Since gmp.h excludes certain functions if stdio.h is not present (but we want all functions), we also add it:
    echo -e "#include <stdio.h>\n#include \"gmp.h\"" > gmp.c
  2. Creating the CIL C file:
    cilly --merge --save-temps --keepunused --noWrap gmp.c
  3. Removing compiler builtins (we don't want to translate them):
    perl -0pi -e 's/\/\* compiler builtin:.*?\*\/\n//sg' gmp.cil.c
  4. Removing inlined functions (we don't want to translate them):
    perl -0pi -e 's/__inline extern [^;]*?{.*?\n}\n}\n//sg' gmp.cil.c


Now you can translate the created gmp.cil.c with C2Eif. It will create an Eiffel library that is an interface to the C library.