ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
JinShil has joined #zig
SimonN has joined #zig
SimonNa has quit [Ping timeout: 260 seconds]
darithorn has quit [Quit: Leaving]
sherjilozair has joined #zig
<donpdonp> i have a C to zig question.
<donpdonp> c code: struct nk_context ctx;
<donpdonp> zig: var ctx: c.nk_context = <?>
<donpdonp> the c code allocates ram to hold the nk_context, but im not sure how to state that in zig
quc has joined #zig
davr0s has joined #zig
<donpdonp> and in other news, this graphics lib .h is giving zig some trouble. any reference to a struct from the lib throws @compileLog(@sizeOf(c.struct_nk_context)); => analyze.cpp:4302: bool handle_is_ptr(TypeTableEntry*): Assertion `type_entry->data.unionation.complete' failed.
m6w6 has quit [Quit: ZNC - http://znc.in]
m6w6 has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
sherjilozair has quit [Quit: Leaving...]
<donpdonp> more type loopyness.
<donpdonp> var ret_func = c.glfwGetProcAddress(fname); //?extern fn() void
<donpdonp> @ptrCast(?&c_void, ret_func); => error: cast discards const qualifier
* donpdonp doesnt see a const to discard
<donpdonp> or maybe simpler still, just want to turn a fn() into a voidptr
<donpdonp> return &c_void(c.glfwGetProcAddress(fname)); error: invalid cast from type '?extern fn() void' to 'c_void'
davr0s has joined #zig
<donpdonp> ok I cheated.
<donpdonp> var ramptr = @ptrToInt(ret_func);
<donpdonp> var vptr = @intToPtr(?&c_void, ramptr);
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Hejsil has joined #zig
davr0s has joined #zig
<Hejsil> donpdonp, struct nk_context ctx; == var ctx: c.nk_context = undefined;
<Hejsil> All functions are const pointers, so you can't cast then to none const pointers
<Hejsil> @ptrCast(?&const c_void, func) should work
<Hejsil> This makes sense, as the memory pointed to by a function pointer, probably isn't something you should change :)
<donpdonp> well one c func returns a fn ptr, the other c func wants a void ptr.
<donpdonp> casting to const c_void works but breaks what the 2nd function is looking for.
<Hejsil> Aaah
<Hejsil> Ye, that's a thing
<Hejsil> Hmm
<donpdonp> the ptr->int int->ptr hack seems to be a fine hack for now. :)
<Hejsil> Well, I think your solution is the best way of discarding const
<donpdonp> in addition to learning zig's c-interop, im learning that opengl is too low level to put somethingson the screen.
<Hejsil> Why does the other function take a void ptr and not a fn ptr?
<Hejsil> Is it some "generic" stuff?
<donpdonp> not sure why. archaic opengl stuff
<Hejsil> Hmm, ooh well
* donpdonp goes to lunch
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<donpdonp> more ptr fun. this one should be easy for someone :)
<donpdonp> var argc: c_int = 0;
<donpdonp> var argv: [][]u8 = [][]u8{};
<donpdonp> c.gtk_init(&argc, argv.ptr);
<donpdonp> error: expected type '?&?&?&u8', found '&[]u8'
<donpdonp> c.gtk_init(&argc, argv.ptr);
<donpdonp> ^
<donpdonp> ok well not as zig-ish but this worked
<donpdonp> var argv: ?&?&u8 = undefined;
<donpdonp> c.gtk_init(&argc, &argv);
JinShil has quit [Quit: Leaving]
<Hejsil> donpdonp, you could probably do this: https://pastebin.com/FJcVUCS2
* donpdonp nods
<donpdonp> is there a way to dump all the symbols in c.*
<donpdonp> im including #define g_signal_connect(... yet error: no member named 'g_signal_connect' in '(C import)'
<Hejsil> It might be a macro that Zig wasn't able to translate
<Hejsil> Zig translates C headers to Zig
<Hejsil> And macros are tricky
<donpdonp> nod. thats pretty cool. .h -> .zig
<donpdonp> well then this road to a gui lib just got longer... (country guitar riff here)
<Hejsil> You can do 'zig translate-c some-file.c' and it'll print the translated version to stdout
<donpdonp> it gets stuch on missing paths and a maze of sub-includes
<Hejsil> Ooh, ye, you probably need the include path with that command
<Hejsil> I think the flag is -isystem
<Hejsil> or something
<donpdonp> is webasm on the roadmap for a zig target?
<donpdonp> 'WebAssembly has 32-bit and 64-bit architecture variants, called wasm32 and wasm64'
<donpdonp> ohh i see them now
<donpdonp> niiice.
<donpdonp> $ zig build --verbose-cimport 2>&1 |grep -i signal_connect
<donpdonp> that found the function that the macro expands to, so thats a good lead.
davr0s has joined #zig
aiwakura has quit [Ping timeout: 268 seconds]
aiwakura has joined #zig
steveno_ has joined #zig
jjido has joined #zig
arBmind has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
steveno_ has quit [Ping timeout: 265 seconds]
steveno_ has joined #zig
arBmind has quit [Ping timeout: 256 seconds]
arBmind has joined #zig
SimonN has quit [Quit: Leaving]
SimonNa has joined #zig
return0e_ has quit [Read error: Connection reset by peer]
Hejsil has quit [Ping timeout: 260 seconds]
darithorn_ has joined #zig
darithorn_ has quit [Ping timeout: 248 seconds]
Hejsil has joined #zig
davr0s has joined #zig
bheads has joined #zig
bheads_ has quit [Ping timeout: 252 seconds]
Ichorio has joined #zig
arBmind has quit [Quit: Leaving.]
<andrewrk> donpdonp, if you can come up with a small C test case that would be the first step towards fixing it
MajorLag2 has joined #zig
MajorLag1 has quit [Ping timeout: 252 seconds]
Hejsil has quit [Ping timeout: 260 seconds]
jjido has quit [Ping timeout: 248 seconds]
return0e has joined #zig
return0e has quit [Ping timeout: 256 seconds]
steveno_ has quit [Remote host closed the connection]
return0e has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
Ichorio has quit [Ping timeout: 245 seconds]
darithorn_ has joined #zig
darithorn has joined #zig
quc has quit [Remote host closed the connection]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
alandipert has quit [Remote host closed the connection]
alandipert has joined #zig
alandipert has quit [Client Quit]
alandipert has joined #zig