ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
jmdaemon has joined #crystal-lang
greenbigfrog has quit [Ping timeout: 246 seconds]
greenbigfrog has joined #crystal-lang
hightower2 has joined #crystal-lang
greenbigfrog has quit [Ping timeout: 252 seconds]
greenbigfrog has joined #crystal-lang
jmdaemon has quit [Ping timeout: 252 seconds]
jmdaemon has joined #crystal-lang
quazimodo has quit [Ping timeout: 252 seconds]
jmdaemon has quit [Ping timeout: 252 seconds]
quazimodo has joined #crystal-lang
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 268 seconds]
jmdaemon has joined #crystal-lang
ur5us has quit [Ping timeout: 248 seconds]
<SamantazFox> Blacksmoke16 Cool, thanks :D
<SamantazFox> I'm wondering: what does `{{@type}}` does in all those macros?
ur5us has joined #crystal-lang
_ht has joined #crystal-lang
ur5us has quit [Ping timeout: 248 seconds]
_ht has quit [Quit: _ht]
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
ht_ has joined #crystal-lang
_ht has quit [Ping timeout: 256 seconds]
ht_ is now known as _ht
Sankalp has quit [Ping timeout: 252 seconds]
Sankalp has joined #crystal-lang
_ht has quit [Quit: _ht]
_ht has joined #crystal-lang
jmdaemon has quit [Ping timeout: 252 seconds]
Sankalp has quit [Ping timeout: 252 seconds]
Sankalp has joined #crystal-lang
<FromGitter> <Blacksmoke16> It's a workaround for a compiler bug
<FromGitter> <Blacksmoke16> @SamantazFox https://github.com/crystal-lang/crystal/issues/7975
quazimodo has quit [Ping timeout: 252 seconds]
jmdaemon has joined #crystal-lang
jmdaemon has quit [Ping timeout: 260 seconds]
<SamantazFox> Blacksmoke16: Ok, thanks :)
jmdaemon has joined #crystal-lang
hightower3 has quit [Ping timeout: 268 seconds]
jmdaemon has quit [Ping timeout: 248 seconds]
hightower2 has joined #crystal-lang
<FromGitter> <jrei:matrix.org> Hi, what's the recommended way to convert a given `name : String` to `char name[80]`, which is defined in a lib C struct?
<FromGitter> <jrei:matrix.org> Also can `char name[80]` be translated to `name : Char[80]`? This means, I can allocate a `StaticArray(Char, 80)`, then iterate on the string with each_char to assign each char to the static array
<FromGitter> <Blacksmoke16> iirc isnt `char` actually `UInt8`?
<mps> CHAR_MIN CHAR_MAX
_ht has quit [Quit: _ht]
__ht has joined #crystal-lang
__ht is now known as _ht
<FromGitter> <jrei:matrix.org> Yes in C, I can check if the Char is ascii I suppose
jmdaemon has joined #crystal-lang
<SamantazFox> I'm confused
<SamantazFox> why is `type` not recognized as a variable here?
<SamantazFox> (I tried other names, same result)
<FromGitter> <Blacksmoke16> i think you want `@type <= type` and not `is_a?`
<SamantazFox> If `Foo` includes `Bar`, that makes `Bar` and ancestor of `Foo`?
<FromGitter> <Blacksmoke16> i think so yea
<FromGitter> <Blacksmoke16> other way around
<FromGitter> <Blacksmoke16> `Bar <= Foo` would be like "Is Foo included in Bar?"
<SamantazFox> ah, right!
<SamantazFox> but then, why `.is_a?` doesn't work?
<SamantazFox> it should always return false, no?
<FromGitter> <Blacksmoke16> prob same reason you cant pass a local var is `is_a?` in normal code
<FromGitter> <jrei:matrix.org> in my case maybe I could just check the size before passing it to the C struct...
<FromGitter> <Blacksmoke16> that would prob work, since `.to_slice` would have each codepoint in it
<FromGitter> <Blacksmoke16> then could use that slice to create the static array?
ur5us has joined #crystal-lang
<FromGitter> <jrei:matrix.org> I'm looking to an easy way, maybe we can cast
<FromGitter> <Blacksmoke16> does it have to be a static array?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/ehxd is what i was thinking
<FromGitter> <Blacksmoke16> question then is what to do with the rest of the uninitialized static array if the string is less than 80 bytes?
<FromGitter> <Blacksmoke16> if that matters...
<FromGitter> <Blacksmoke16> actually checking `String#bytesize` and just using `String#each_byte` would prob be enough versus going to a slice in between
<FromGitter> <jrei:matrix.org> I made something like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=63dad6736376f2625253dc22]
<FromGitter> <jrei:matrix.org> now I have to deal with ioctl errors, no idea how to debug that
<FromGitter> <jrei:matrix.org> and know what's wrong...
<FromGitter> <jrei:matrix.org> Also I think it may be `LibC::Char[80]`
<FromGitter> <Blacksmoke16> using those aliases is a good idea yea, but thats basically just `UInt8[80]` fwiw
<FromGitter> <jrei:matrix.org> Yep, `char.ord.to_u8` did it
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Char.html#bytes%3AArray%28UInt8%29-instance-method is another option
<FromGitter> <Blacksmoke16> for multi-byte strings
<FromGitter> <jrei:matrix.org> hum no got "Bad address" :/
<FromGitter> <Blacksmoke16> er https://crystal-lang.org/api/master/Char.html#each_byte%28%26%29%3ANil-instance-method
<FromGitter> <jrei:matrix.org> Ha good to know
<FromGitter> <Blacksmoke16> `Char#each_byte`
<FromGitter> <jrei:matrix.org> I added a pointerof(some_struct), well I got it working I think :). ⏎ UTF8 and C may be not a good idea
<FromGitter> <jrei:matrix.org> I'll keep it ascii
_ht has quit [Quit: _ht]
hightower2 has quit [Ping timeout: 252 seconds]
hightower2 has joined #crystal-lang
quazimodo has joined #crystal-lang
<SamantazFox> Blacksmoke16: Here is the final code I got with https://bpa.st/J5KTY
<SamantazFox> Thanks a lot for your help (again lol)
<FromGitter> <Blacksmoke16> 👍 np
quazimodo has quit [Ping timeout: 268 seconds]
quazimodo has joined #crystal-lang
ua_ has quit [Excess Flood]
ua_ has joined #crystal-lang