IRC channel logs


back to list of logs

<apteryx>me neither... that must be
<apteryx>that must be months old
<lilyp>sneek later tell zzo38: re "guile without unicode", you might want to make use of bytevectors. Guile uses unicode for string representation (as you should in the year of our lord 2023), which also limits the character datatype to an integer between 0 and 0x10FFFF
<sneek>Got it.
<seeg123456>hello, is this outdated ? I don't seem to have the `guild compile-ffi` command
<dokma>guild is from guile 2.2
<dokma>which version do you have?
<dokma>seeg123456: ^^^
<seeg123456>Guile 3
<seeg123456>I'm using recent guix in fact
<dokma>Guile 3 dropped guild
<seeg123456>OK basically I need to use the geotiff library and wanted to try out guile to use that c lib
<seeg123456>I have some simple code working already with dynamic-fun
<dokma>You should be able to use ffi out of the box if I recall correctly.
<dokma>(use-modules (system foreign-library))
<dokma>and just keep chugging
<lloda>sneek: seen mwette
<sneek>mwette was in #guile 4 days ago, saying: graywolf: I think the macro needs an eval-when set-up.
<seeg123456>how can I use the <stdio.h> stdout in guile? I have some obscure debugging C function that could print to stdout
<seeg123456>but using (scm->pointer (current-output-port)) doesn't work
<dokma>Use as in write to it?
<seeg123456>basically the C function accepts a 'FILE *'
<dokma>Something like: (define stdio (dynamic-link ""))
<dokma>(define stdout (c-define-constant "FILE *" "stdout" stdio))
<dokma>and use foreign-procedure to call fwrite
<seeg123456>ah ok thanks
<seeg123456>hm, i only seem to have but when I use that I get a 'glibc detected an invalid stdio handle'
<dokma>there's no way that you don't have libc on your system. You wouldn't even be able to boot
<dokma>ldd $(which guile)
<dokma>and look for c library
<dokma>maybe ?
<seeg123456>yes, i'm using guile
<seeg123456>so it's /gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/ in fact
<dokma>guile via guix ?
<seeg123456>well, i need guix to install some c libs
<seeg123456>i guess i could use system guile
<dokma>pull that one in with dynamic-link
<dokma>it will probably find the guix one
<dokma>then it should be able to see stdout
<seeg123456>like this? (define stdio (dynamic-link "/gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35/lib/"))
<dokma>it should probably be just and it will search the load path
<seeg123456>well, i seem to have problems with that in guix
<dokma>guile -c '(display %load-path) (newline)'
<seeg123456>ok will check, need to leave for 20 min
<mwette>there is (port->fdes (current-output-port)) to give you the fd; then use ffi routines to call the C function fdopen to get the FILE*
<mwette>I don't believe guild has been removed from guile; on my guix machine I have guile installed and it provided guild.
<lloda>i confirm that
<dokma>mwette: via guix?
<dokma>then I'm wrong about guild
<dokma>I thought it was removed
<mwette>I could be wrong about which package. Is there a guix command to tell where a command comes from?
<lloda>i build guile from source, no guix. guild is in there
<dokma>guix package --list-generations /bin/ls
<dokma>to find which package installed /bin/ls
<lloda>i can't find trace of 'guild compile-ffi' tho. There's only 'guild compile'
<dokma>ohhh... so maybe only that was removed
<mwette>I tried `guix locate guild' but got an sqlite-error: attempt to write a readonly database
<mwette>compile-ffi comes with nyacc. So you'd need to `guix install nyacc'
<morenonatural>hey, sup everyone... the example code for `open-input-pipe` is not working for me in a MacOS M1 (even when correctly replacing `date` with `gdate`) ... `(read-line port)` consistently returns #<eof>
<mwette>The FFI is not great with functions with variadic args
<morenonatural>how can I help with this situation? is this a known problem?
<seeg123456>yes, guild is in guix, i can confirm as well, and i have guile 3.0.9
<seeg123456>i still get "glibc detected an invalid stdio handle" when using "/gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/"
<dthompson>guild is def still around. it's how build systems invoke guile's compiler.
<lloda>morenonatural: have you seen
<civodul>mwette: re ‘guix locate’, could you run ‘strace -o log guix locate guild’ to see which file it’s trying to write to?
<morenonatural> lloda: sounds like it's this problem, will keep an eye out for this one... many thanks
<sneek>Yey! dsmith-work is back :)
<dsmith-work>sneek, botsnack
<dsmith-work>Wednesday Greetings, Guilers
<seeg123456>is it possible in guile, having a struct pointer `x` to get the value of `x->SomeField` ? Or do I need to redefine the whole big C structure with bytevectors:struct ?
<seeg123456>sorry, scheme-bytestructures:struct
<mwette>civodul: will do
<mwette>civodul: bug#66612
<mwette>seeg123456: can you paste your c struct def in (or equiv)?
<seeg123456>Basically it looks like this
<seeg123456>I have a pointer to gtiff. I was able to pull some info when this is wrapped in bytestructures
<seeg123456>My C is rusty but I think a C struct is just a contiguous slice of memory bits and when you reference ptr->field the compiler translates that to a pointer offset, similar to arrays (head + index * (sizeof t))
<seeg123456>Hence guile wouldn't know anything about a structure in a compiled lib
<seeg123456>Just now I found this so maybe one can do without bytestructures?
<seeg123456>I don't know about guile history but it seems to me that ffi in v3 is bit different than the one in v2
<seeg123456>It wound be nice it make-c-struct worked with standard guile records
<old>kind of work. It is slow tho (I'm not the best with syntax transformer)
<old>(see example at the end of the file)
<mwette>a bit of a hack for ffi-helper, but it worked:
<mwette>^ on x86_64
<mwette>this is for bytestructures; you'll want to replace fh:pointer fh:function with bs:pointer