7.3 Using the Foreign Parser

The interface is the function foreign-parser:process-foreign-file.

Suppose we wish to generate the FLI definitions which interface to the C example from Modifying a string in a C function. The header file
test.h
needs to be slightly different depending on the platform.

Windows version:

__declspec(dllexport) void __cdecl modify(char *string)

Linux/Unix/Macintosh version:

void modify(char *string)

Load the Foreign Parser:

(require "foreign-parser")

Now generate prototype FLI definitions:

(foreign-parser:process-foreign-file

"test.h"

:case-sensitive nil)

=>

;;; Output dff file #P"test-dff.lisp"

;;; Parsing source file "test.h"

;;; Process-foreign-file : Preprocessing file

;;; Process-foreign-file : Level 1 parsing

;;; Process-foreign-file : Selecting foreign forms

NIL

You should now have a Lisp file
test-dff.lisp
containing a form like this: