common lisp 调用 dll function

common lisp调用dll函数例子:

int add(int a,int b){
    return a+b;
}
int sub(int a ,int b){
    return a-b;
}
win下gcc编译生成dll:gcc add.c -shared -o libadd.dll 新建lisp文件test-add.lisp

(asdf:oos 'asdf:load-op :cffi)

(defpackage :cffi-user
    (:use :common-lisp :cffi))

(in-package :cffi-user)
 (define-foreign-library libadd

  (:unix (:or "libadd.so"))

  (:darwin (:or "libadd.dylib"))
(:windows (:or "libadd.dll" #p"D:/dev/c/libadd.dll"))
  (t (:default "libadd")))
(use-foreign-library libadd)
(defcfun ("add" c-add) :int (a :int) (b :int))
(defcfun "add" :int (a :int) (b :int))

(defcfun ("sub" c-sub) :int (a :int) (b :int))
(defcfun "sub"  :int (a :int) (b :int))
然后调用的时候在cl-user输入:
(c-sub 1 2)
(sub 10 20)
(add 10 (c-sub 100 20))

  1. 表情都不能发,差评
  2. 卧槽,表情都都不能发
    1. 目前不支持表情,哈,