- inline-compile STRING #!optional OPTIONSprocedure
Compiles the C source code in STRING dynamically. If a compiled library with the same source text is currently loaded (and has been cached), then nothing is done. If it is not loaded, the inline cache is consulted, whether a compiled file for the same text is stored, and, if it is, it's loaded and the procedure is returned. If no such file exists, the compiler (``csc'') is invoked to create a compiled library (with any extra options passed in OPTIONS), which is stored in the cache. The code will be compiled as if wrapped in #>! ... <#. Note that you will have to shield #include forms, if you don't want them to be processed by the FFI parser:
(inline #<<EOF #ifndef CHICKEN #include "gd.h" #include <stdio.h> #endif void genimages(int w, int h) { gdImagePtr im; FILE *pngout, *jpegout; int black; int white; im = gdImageCreate(w, h); black = gdImageColorAllocate(im, 0, 0, 0); white = gdImageColorAllocate(im, 255, 255, 255); gdImageLine(im, 0, 0, w - 1, h - 1, white); pngout = fopen("test.png", "wb"); jpegout = fopen("test.jpg", "wb"); gdImagePng(im, pngout); gdImageJpeg(im, jpegout, -1); fclose(pngout); fclose(jpegout); gdImageDestroy(im); } EOF "-L -lgd -L -lpng -L -lz -L -ljpeg -L -lfreetype" ) (genimages 64 64)