Update readme

This commit is contained in:
retropikzel 2025-06-28 09:28:31 +03:00
parent b8a491e8c6
commit f2cf940aa6
3 changed files with 38 additions and 23 deletions

View File

@ -88,15 +88,24 @@ Required versions:
- Chibi > 0.11 - Chibi > 0.11
- At the only 0.11 is out so build from git - At the only 0.11 is out so build from git
- Chicken >= 5.4.0 < 6 - Chicken >= 5.4.0 < 6
- Gauche >= 0.9.15
- Does not yet work with snow-chibi install
- Guile >= 3 - Guile >= 3
- Does not yet work with snow-chibi install
- Has include bug, might not work on all situations - Has include bug, might not work on all situations
- Kawa >= 3.11 and Java >= 22 - Kawa >= 3.11 and Java >= 22
- Needs arguments - Needs arguments to enable FFI
- -J--add-exports=java.base/jdk.internal.foreign.abi=ALL-UNNAMED - -J--add-exports=java.base/jdk.internal.foreign.abi=ALL-UNNAMED
- -J--add-exports=java.base/jdk.internal.foreign.layout=ALL-UNNAMED - -J--add-exports=java.base/jdk.internal.foreign.layout=ALL-UNNAMED
- -J--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED - -J--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED
- -J--enable-native-access=ALL-UNNAMED - -J--enable-native-access=ALL-UNNAMED
- -J--enable-preview - -J--enable-preview
- So that snow-chibi installed library is found
- -Dkawa.import.path=/usr/local/share/kawa
- -Dkawa.import.path=/usr/local/share/kawa/lib
- Mosh >= 0.2.9-rc1
- Racket >= 8.16 [cs]
- Sagittarius >= 0.9.13
- STklos > 2.10 - STklos > 2.10
- At the time only 2.10 is out so build from git - At the time only 2.10 is out so build from git
@ -152,13 +161,15 @@ Required versions:
[https://snow-fort.org/](https://snow-fort.org/) [https://snow-fort.org/](https://snow-fort.org/)
Installable with snow-chibi for following implementations. snow-chibi --impls=IMPLEMENTATION install "(foreign c)"
- Chibi You can test that library is found by your implementation like this:
- Kawa
- STklos
### Manul cp tests/hello.scm /tmp/hello.scm
cd /tmp
IMPLEMENTATION hello.scm
### Manual
Either download the latest release from Either download the latest release from
[https://git.sr.ht/~retropikzel/foreign-c/refs](https://git.sr.ht/~retropikzel/foreign-c/refs) [https://git.sr.ht/~retropikzel/foreign-c/refs](https://git.sr.ht/~retropikzel/foreign-c/refs)

View File

@ -107,8 +107,13 @@ Schemes - 0.10.0</title>
<li>At the only 0.11 is out so build from git</li> <li>At the only 0.11 is out so build from git</li>
</ul></li> </ul></li>
<li>Chicken &gt;= 5.4.0 &lt; 6</li> <li>Chicken &gt;= 5.4.0 &lt; 6</li>
<li>Gauche &gt;= 0.9.15
<ul>
<li>Does not yet work with snow-chibi install</li>
</ul></li>
<li>Guile &gt;= 3 <li>Guile &gt;= 3
<ul> <ul>
<li>Does not yet work with snow-chibi install</li>
<li>Has include bug, might not work on all situations</li> <li>Has include bug, might not work on all situations</li>
</ul></li> </ul></li>
<li>Kawa &gt;= 3.11 and Java &gt;= 22 <li>Kawa &gt;= 3.11 and Java &gt;= 22
@ -122,6 +127,9 @@ Schemes - 0.10.0</title>
<li>-Jenable-preview</li> <li>-Jenable-preview</li>
</ul></li> </ul></li>
</ul></li> </ul></li>
<li>Mosh &gt;= 0.2.9-rc1</li>
<li>Racket</li>
<li>Sagittarius</li>
<li>STklos &gt; 2.10 <li>STklos &gt; 2.10
<ul> <ul>
<li>At the time only 2.10 is out so build from git</li> <li>At the time only 2.10 is out so build from git</li>
@ -456,11 +464,9 @@ cp -r foreign-c/foreign snow/</code></pre>
<p>Example:</p> <p>Example:</p>
<pre><code>(define-c-library libc <pre><code>(define-c-library libc
(list &quot;stdlib.h&quot;) (list &quot;stdlib.h&quot;)
&quot;c&quot; libc-name
&#39;((additional-versions (&quot;&quot; &quot;0&quot; &quot;6&quot;)) &#39;((additional-versions (&quot;&quot; &quot;0&quot; &quot;6&quot;))
(additional-paths (&quot;.&quot;))))</code></pre> (additional-paths (&quot;.&quot;))))</code></pre>
<p>Note that libc is exported by this library so you might not
need to load it.</p>
<h4 id="notes">Notes</h4> <h4 id="notes">Notes</h4>
<ul> <ul>
<li>Do not cond-expand inside the arguments, that might lead to <li>Do not cond-expand inside the arguments, that might lead to
@ -485,9 +491,7 @@ cp -r foreign-c/foreign snow/</code></pre>
<p>Defines a new foreign function to be used from Scheme <p>Defines a new foreign function to be used from Scheme
code.</p> code.</p>
<p>Example:</p> <p>Example:</p>
<pre><code>(cond-expand <pre><code>(define-c-library libc &#39;(&quot;stdlib.h&quot;) libc-name &#39;(&quot;6&quot;))
(windows (define-c-library libc &#39;(&quot;stdlib.h&quot;) &quot;ucrtbase&quot; &#39;()))
(else (define-c-library libc &#39;(&quot;stdlib.h&quot;) &quot;c&quot; &#39;(&quot;6&quot;))))
(define-c-procedure c-puts libc &#39;puts &#39;int &#39;(pointer)) (define-c-procedure c-puts libc &#39;puts &#39;int &#39;(pointer))
(c-puts &quot;Message brought to you by foreign-c!&quot;)</code></pre> (c-puts &quot;Message brought to you by foreign-c!&quot;)</code></pre>
<h4 id="notes-1">Notes</h4> <h4 id="notes-1">Notes</h4>
@ -533,9 +537,7 @@ cp -r foreign-c/foreign snow/</code></pre>
code.</p> code.</p>
<p>Example:</p> <p>Example:</p>
<pre><code>; Load the shared library <pre><code>; Load the shared library
(cond-expand (define-c-library libc-stdlib &#39;(&quot;stdlib.h&quot;) libc-name &#39;(&quot;&quot; &quot;6&quot;))
(windows (define-c-library libc-stdlib &#39;(&quot;stdlib.h&quot;) &quot;ucrtbase&quot; &#39;()))
(else (define-c-library &#39;(&quot;stdlib.h&quot;) &quot;c&quot; &#39;(&quot;&quot; &quot;6&quot;))))
; Define C function that takes a callback ; Define C function that takes a callback
(define-c-procedure qsort libc-stdlib &#39;qsort &#39;void &#39;(pointer int int callback)) (define-c-procedure qsort libc-stdlib &#39;qsort &#39;void &#39;(pointer int int callback))
@ -825,17 +827,19 @@ func(&amp;i);</code></pre>
<p>Returns a newly allocated (unless empty) string whose <p>Returns a newly allocated (unless empty) string whose
character sequence is encoded by the given c-bytevector.</p> character sequence is encoded by the given c-bytevector.</p>
<h3 id="utilities">Utilities</h3> <h3 id="utilities">Utilities</h3>
<p><strong>libc</strong></p> <p><strong>libc-name</strong></p>
<p>Since the library uses C standard internally, and that is <p>Name of the C standard library on the current operating
most likely library to have different name on different system. Supported OS:</p>
operating systems. For example libc.so on Linux, ucrtbase.dll on <ul>
windows and libroot.so on Haiku. It makes sense to export it, <li>Windows</li>
saving the users the trouble of figuring out which named shared <li>Linux</li>
library they should load.</p> <li>Haiku</li>
</ul>
<p>See foreign/c/libc.scm to see which headers are included and <p>See foreign/c/libc.scm to see which headers are included and
what shared libraries are loaded.</p> what shared libraries are loaded.</p>
<p>Example:</p> <p>Example:</p>
<pre><code>(define-c-procedure c-puts libc &#39;puts &#39;int &#39;(pointer)) <pre><code>(define-c-library libc &#39;(&quot;stdlib.h&quot;) libc-name &#39;(&quot;&quot; &quot;6&quot;))
(define-c-procedure c-puts libc &#39;puts &#39;int &#39;(pointer))
(c-puts &quot;Message brought to you by foreign-c!&quot;)</code></pre> (c-puts &quot;Message brought to you by foreign-c!&quot;)</code></pre>
<h3 id="environment-variables">Environment variables</h3> <h3 id="environment-variables">Environment variables</h3>
<p>Setting environment variables like this on Windows works for <p>Setting environment variables like this on Windows works for

Binary file not shown.