Questions tagged [cffi]

CFFI, the Common Foreign Function Interface, for Common Lisp. For Python CFFI, see the [python-cffi] tag.

CFFI, the Common Foreign Function Interface, purports to be a portable foreign function interface for Common Lisp.

Check out Homepage

142 questions
3
votes
1 answer

How do I get the list of all environment variables available in a Lisp process?

I want to enumerate the list of all environment variables available in my Lisp process. I want the same list that is returned by the C variable environ. Neither SBCL nor Clozure CL seem to provide it out of the box. Can I do it using CFFI?
Chaitanya Gupta
  • 4,043
  • 2
  • 31
  • 41
3
votes
1 answer

Common Lisp CFFI: Assign a struct value to an array index

How can I assign the value of an index of a foreign array to be the value of a foreign struct. For example, the following: (cffi:with-foreign-objects ((x '(:struct my-struct)) (arr '(:struct my-struct) 2)) (setf…
user1569339
  • 683
  • 8
  • 20
3
votes
1 answer

CFFI and win32 clipboard access

I'm a newbie in Common Lisp and did some experiments on it. I was trying hard to get some access to the windows clipboard, then I found this reference: https://groups.google.com/forum/#!topic/comp.lang.lisp/hyNqn2QhUY0 That was perfect, except for…
rand
  • 53
  • 4
3
votes
2 answers

cffi function call hangs

I want to use stat(2) from Common Lisp. I've defined the structs used by the stat function: (cffi:defctype mode_t :unsigned-int) (cffi:defctype ino_t :unsigned-int) (cffi:defctype dev_t :int) (cffi:defctype nlink_t :int) (cffi:defctype uid_t…
Florian Margaine
  • 58,730
  • 15
  • 91
  • 116
3
votes
1 answer

Passing and returning structs to C functions on stack from Common Lisp with CFFI

This is sort-of a follow-up to the question Common lisp, CFFI, and instantiating c structs, so basically this question is about passing and returning c-structs to and from c-functions on the stack from Common Lisp with CFFI. The answer to the…
Flash
  • 107
  • 8
3
votes
1 answer

How would I convert a c++ vector to a lisp vector in a 0(1) operation

I have these C bindings for the C++ vector which I have wrapped in CFFI. I know how to create vectors with std_carrayTovector and convert the data back to an int pointer with std_vectorToCArray so that I can retrieve data from it in Lisp…
user3517736
  • 329
  • 1
  • 4
  • 14
3
votes
2 answers

recommended naming convention for cffi/foreign types

In common lisp, is there a recommended naming convention for foreign types? (and types in general)? For example: (cffi:defctype glyph-index-t :uint32) (cffi:defcstruct Point (x :int32) (y :int32)) (cffi:define-foreign-library fontlib (t…
SigTerm
  • 26,089
  • 6
  • 66
  • 115
2
votes
2 answers

How to call a foreign function with an output pointer argument?

Let’s say there is a C function: int do_something(int *output); I can define it in lisp with cffi like this: (cffi:defcfun ("do_something" %do-something) :int (output :pointer)) How can I call it and get the value of output? I have looked at…
Philipp Ludwig
  • 3,758
  • 3
  • 30
  • 48
2
votes
0 answers

How do I use Common Lisp CFFI to close all windows of an Gtk4 app?

It appears that the way to close a Gtk4 library is by closing all the windows. The gir based bindings only allow the closing of a single window. https://docs.gtk.org/glib/type_func.List.foreach.html seems to be the way to go. I want to pass to it…
ruby_object
  • 1,229
  • 1
  • 12
  • 30
2
votes
0 answers

Loading a library via CFFI under swank/slime

I'm seeing an odd behaviour when loading shared libraries under slime/swank. From a command line REPL: * (asdf:load-system :cffi) T * (cffi:load-foreign-library "s:/src/lla/lib/libopenblas-0.3.21.dll") #
CL-USER
  • 715
  • 3
  • 9
2
votes
1 answer

Defining a parameter from an input variable in a Fortran subroutine

A part of a code I have has constants defined inside the module under consideration. Here's what I am talking about: real(RealExt), parameter :: grav_acc = 9.80665 real(RealExt), parameter :: r_gas_dry = 287.026 real(RealExt), parameter ::…
Senku02
  • 83
  • 6
2
votes
1 answer

Win32 MessageBox with SBCL foreign interface

I am trying to figure out how to call the Win32 function MessageBox with the SBCL foreign interface. The MessageBox function implemented in "user32.dll" is described as follow: int MessageBox( [in, optional] HWND hWnd, [in, optional] LPCTSTR…
Robert
  • 2,711
  • 7
  • 15
2
votes
2 answers

Build and install of cffi fails

(venv) ~/P/PickleballMaps ❯❯❯ pip install cffi==1.11.0 …
JGV
  • 163
  • 3
  • 14
2
votes
0 answers

Version mismatch: this is the 'cffi' RAPIDS on Colab

# Install RAPIDS !git clone https://github.com/rapidsai/rapidsai-csp-utils.git !bash rapidsai-csp-utils/colab/rapids-colab.sh stable import sys, os, shutil sys.path.append('/usr/local/lib/python3.7/site-packages/') os.environ['NUMBAPRO_NVVM'] =…
Asif Ahmed
  • 21
  • 1
2
votes
1 answer

Calling function from Fortran DLL with Char as parameter

I'm trying to call a function (bubblesort) from a 3rd party Fortran DLL with Python. My problem is passing a char to the function. I got it working with cffi as shown below, but I want to use ctypes. The cffi version: import numpy as np import cffi…
NicoC0D3S
  • 43
  • 6
1 2
3
9 10