LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-24-2024, 08:11 PM   #1
FossilizedDaemon
LQ Newbie
 
Registered: Jun 2023
Posts: 18
Blog Entries: 1

Rep: Reputation: 1
Unhappy How to Include C Code From Scratch in Common Lisp


Hello everyone,

As an exercise in learning more about programming, and to help with another project of mine, I want to learn how to write bindings for C in Common Lisp. I know enough about both languages to read and understand the functions, but I have never written bindings in either and only have used CFFI in Common Lisp. I tried reading over their codebase to learn more, but it being a huge project I keep getting caught up in different parts. I looked around online for tutorials on including C from scratch in Common Lisp, but can only find resources on using CFFI. I was curious if anyone here had any sources or pointers. Nothing insane, just a simple "hello world" for using a basic C function from CL.

Thank you.
 
Old 06-25-2024, 05:34 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,793

Rep: Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087
If you don't want to use CFFI, then you have to use an implementation specific method. Which Common Lisp implementation are you using?
 
Old 06-25-2024, 11:15 AM   #3
FossilizedDaemon
LQ Newbie
 
Registered: Jun 2023
Posts: 18

Original Poster
Blog Entries: 1

Rep: Reputation: 1
Talking

Quote:
Originally Posted by ntubski View Post
If you don't want to use CFFI, then you have to use an implementation specific method. Which Common Lisp implementation are you using?
Disclaimer: I am merely a hobbyist, if I get terminology wrong it is an innocent mistake.

The short answer is: sbcl first, then likely others. The long answer requires some context. I am jumping back into programming after a few years break. I love Common Lisp, but the ecosystem and ANSI standard could be better. The main issue I kept running into was a lack of solid system programming libraries. Libraries like UIOP, OSICAT, etc. are all well and good, but always miss things I need. I started writing my own system programming library to fill this void, cl-os, however in the process found that all libraries like UIOP and OSICAT seem to largely just wrap around different CL implementations, which themselves use the actual C code needed to make calls like exec, execvp, etc. I am wanting to make a library that bypasses all of this madness and goes straight to using the C so we can get things like managing and interacting with processes in Common Lisp without having to use userland programs like ps to do so (i.e. if on OpenBSD you could just do (getpid) and on Unix can just do (exec) etc and not have to wrap every CL out there like UIOP does). I add this context to say, to start SBCL but eventually I would likely add others to make things more portable. I am just playing at the moment and could very well decide to use CFFI, but wanna see how working with C from scratch in CL feels first.
 
Old 06-26-2024, 12:25 AM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,793

Rep: Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087Reputation: 2087
Okay, the SBCL manual has a chapter on this, with an example: http://www.sbcl.org/manual/index.htm...tion-Interface
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Lisp stack overflow" in Common Lisp. zaxonus Programming 5 12-18-2023 12:14 AM
LXer: Lisp Coding Bounty (get a copy of Land of Lisp) LXer Syndicated Linux News 0 10-23-2011 06:41 PM
LISP or COMON LISP Compiler for Debian carspidey Programming 3 04-19-2006 07:46 AM
ali aladdin v agp stinks :scratch: :scratch: :scratch: Mr Marmmalade Linux - Hardware 1 07-08-2003 05:11 AM
Lisp, emacs-lisp aizkorri Programming 1 09-04-2002 06:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration