X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fdocs%2Fusers_guide%2Fffi-chap.sgml;h=6c266cdec304e25280a441c2ecdd48777d673f9d;hb=2dfd507259664e6f28df4a9467a8de34d01d70a0;hp=d622179dc7dfcc3641e806151254bdb7341a736f;hpb=dc801dc275fb8f81d482535b4d6317e234bb10f8;p=ghc-hetmet.git diff --git a/ghc/docs/users_guide/ffi-chap.sgml b/ghc/docs/users_guide/ffi-chap.sgml index d622179..6c266cd 100644 --- a/ghc/docs/users_guide/ffi-chap.sgml +++ b/ghc/docs/users_guide/ffi-chap.sgml @@ -1,11 +1,11 @@ - -Foreign function interface (FFI) + +Foreign function interface (FFI) GHC (mostly) conforms to the Haskell 98 Foreign Function Interface - Addendum 1.0, whose definition is available from http://haskell.org/. + Addendum 1.0, whose definition is available from http://haskell.org/. The FFI support in GHC diverges from the Addendum in the following ways: @@ -18,7 +18,7 @@ GHC implements a number of GHC-specific extensions to the FFI Addendum. These extensions are described in , but please note that programs using + linkend="sec-ffi-ghcexts"/>, but please note that programs using these features are not portable. Hence, these features should be avoided where possible. @@ -56,16 +56,15 @@ use of the foreign function interface in GHC. - Using <literal>foreign export</literal> and <literal>foreign - import ccall "wrapper"</literal> with GHC + Using <literal>foreign export</literal> and <literal>foreign import ccall "wrapper"</literal> with GHC foreign export with GHC When GHC compiles a module (say M.hs) - which uses foreign export or foreign - import "wrapper", it generates two + which uses foreign export or + foreign import "wrapper", it generates two additional files, M_stub.c and M_stub.h. GHC will automatically compile M_stub.c to generate @@ -136,7 +135,7 @@ int main(int argc, char *argv[]) hs_add_root(__stginit_Foo); #endif - for (i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) { printf("%d\n", foo(2500)); } @@ -204,8 +203,7 @@ int main(int argc, char *argv[]) - Using <literal>foreign import ccall "wrapper"</literal> with - GHC + Using <literal>foreign import ccall "wrapper"</literal> with GHC foreign import ccall "wrapper"with GHC @@ -232,7 +230,7 @@ int main(int argc, char *argv[]) When generating C (using the directive), one can assist the C compiler in detecting type errors by using the directive - () to provide + () to provide .h files containing function headers. @@ -269,7 +267,7 @@ from another package, you won't necessarily know what the appropriate options are; but they should be in the package configuration, which GHC knows about. So if you are building a package, remember to put all those options into the package configuration. -See the c_includes field in . +See the c_includes field in . @@ -298,7 +296,7 @@ to be inlined across modules, use the command-line and package-configuration are searched for using the C compiler's usual search path. You can add directories to this search path using the option (see ). + linkend="c-pre-processor"/>). Note: header files are ignored unless compiling via C. If you had been compiling your code using the native code @@ -391,7 +389,7 @@ to be inlined across modules, use the command-line and package-configuration - +