01:35
JinShil has joined #zig
02:06
SimonN has joined #zig
02:08
SimonNa has quit [Ping timeout: 260 seconds]
03:56
darithorn has quit [Quit: Leaving]
04:16
sherjilozair has joined #zig
04:28
<
donpdonp >
i have a C to zig question.
04:28
<
donpdonp >
c code: struct nk_context ctx;
04:29
<
donpdonp >
zig: var ctx: c.nk_context = <?>
04:29
<
donpdonp >
the c code allocates ram to hold the nk_context, but im not sure how to state that in zig
04:37
quc has joined #zig
04:40
davr0s has joined #zig
04:50
<
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.
05:00
m6w6 has joined #zig
05:44
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
05:49
sherjilozair has quit [Quit: Leaving...]
06:28
<
donpdonp >
more type loopyness.
06:28
<
donpdonp >
var ret_func = c.glfwGetProcAddress(fname); //?extern fn() void
06:28
<
donpdonp >
@ptrCast(?&c_void, ret_func); => error: cast discards const qualifier
06:28
* donpdonp
doesnt see a const to discard
06:30
<
donpdonp >
or maybe simpler still, just want to turn a fn() into a voidptr
06:30
<
donpdonp >
return &c_void(c.glfwGetProcAddress(fname)); error: invalid cast from type '?extern fn() void' to 'c_void'
06:54
davr0s has joined #zig
07:00
<
donpdonp >
ok I cheated.
07:00
<
donpdonp >
var ramptr = @ptrToInt(ret_func);
07:00
<
donpdonp >
var vptr = @intToPtr(?&c_void, ramptr);
07:09
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
07:15
Hejsil has joined #zig
07:17
davr0s has joined #zig
07:19
<
Hejsil >
donpdonp, struct nk_context ctx; == var ctx: c.nk_context = undefined;
07:19
<
Hejsil >
All functions are const pointers, so you can't cast then to none const pointers
07:20
<
Hejsil >
@ptrCast(?&const c_void, func) should work
07:21
<
Hejsil >
This makes sense, as the memory pointed to by a function pointer, probably isn't something you should change :)
07:22
<
donpdonp >
well one c func returns a fn ptr, the other c func wants a void ptr.
07:22
<
donpdonp >
casting to const c_void works but breaks what the 2nd function is looking for.
07:23
<
Hejsil >
Ye, that's a thing
07:24
<
donpdonp >
the ptr->int int->ptr hack seems to be a fine hack for now. :)
07:24
<
Hejsil >
Well, I think your solution is the best way of discarding const
07:25
<
donpdonp >
in addition to learning zig's c-interop, im learning that opengl is too low level to put somethingson the screen.
07:26
<
Hejsil >
Why does the other function take a void ptr and not a fn ptr?
07:26
<
Hejsil >
Is it some "generic" stuff?
07:31
<
donpdonp >
not sure why. archaic opengl stuff
07:32
<
Hejsil >
Hmm, ooh well
07:32
* donpdonp
goes to lunch
08:21
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
08:55
<
donpdonp >
more ptr fun. this one should be easy for someone :)
08:55
<
donpdonp >
var argc: c_int = 0;
08:55
<
donpdonp >
var argv: [][]u8 = [][]u8{};
08:55
<
donpdonp >
c.gtk_init(&argc, argv.ptr);
08:55
<
donpdonp >
error: expected type '?&?&?&u8', found '&[]u8'
08:55
<
donpdonp >
c.gtk_init(&argc, argv.ptr);
09:02
<
donpdonp >
ok well not as zig-ish but this worked
09:02
<
donpdonp >
var argv: ?&?&u8 = undefined;
09:02
<
donpdonp >
c.gtk_init(&argc, &argv);
09:08
JinShil has quit [Quit: Leaving]
09:50
<
donpdonp >
is there a way to dump all the symbols in c.*
09:50
<
donpdonp >
im including #define g_signal_connect(... yet error: no member named 'g_signal_connect' in '(C import)'
09:52
<
Hejsil >
It might be a macro that Zig wasn't able to translate
09:53
<
Hejsil >
Zig translates C headers to Zig
09:53
<
Hejsil >
And macros are tricky
09:53
<
donpdonp >
nod. thats pretty cool. .h -> .zig
09:54
<
donpdonp >
well then this road to a gui lib just got longer... (country guitar riff here)
09:54
<
Hejsil >
You can do 'zig translate-c some-file.c' and it'll print the translated version to stdout
09:55
<
donpdonp >
it gets stuch on missing paths and a maze of sub-includes
09:57
<
Hejsil >
Ooh, ye, you probably need the include path with that command
09:57
<
Hejsil >
I think the flag is -isystem
09:57
<
Hejsil >
or something
10:04
<
donpdonp >
is webasm on the roadmap for a zig target?
10:06
<
donpdonp >
'WebAssembly has 32-bit and 64-bit architecture variants, called wasm32 and wasm64'
10:07
<
donpdonp >
ohh i see them now
10:20
<
donpdonp >
$ zig build --verbose-cimport 2>&1 |grep -i signal_connect
10:21
<
donpdonp >
that found the function that the macro expands to, so thats a good lead.
11:43
davr0s has joined #zig
11:58
aiwakura has quit [Ping timeout: 268 seconds]
12:05
aiwakura has joined #zig
12:08
steveno_ has joined #zig
12:43
jjido has joined #zig
13:02
arBmind has joined #zig
13:05
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
13:27
steveno_ has quit [Ping timeout: 265 seconds]
13:27
steveno_ has joined #zig
13:40
arBmind has quit [Ping timeout: 256 seconds]
13:54
arBmind has joined #zig
13:55
SimonN has quit [Quit: Leaving]
13:56
SimonNa has joined #zig
13:59
return0e_ has quit [Read error: Connection reset by peer]
14:12
Hejsil has quit [Ping timeout: 260 seconds]
14:12
darithorn_ has joined #zig
14:32
darithorn_ has quit [Ping timeout: 248 seconds]
14:51
Hejsil has joined #zig
14:54
davr0s has joined #zig
15:35
bheads has joined #zig
15:36
bheads_ has quit [Ping timeout: 252 seconds]
15:49
Ichorio has joined #zig
15:51
arBmind has quit [Quit: Leaving.]
16:19
<
andrewrk >
donpdonp, if you can come up with a small C test case that would be the first step towards fixing it
16:35
MajorLag2 has joined #zig
16:36
MajorLag1 has quit [Ping timeout: 252 seconds]
16:43
Hejsil has quit [Ping timeout: 260 seconds]
16:44
jjido has quit [Ping timeout: 248 seconds]
18:14
return0e has joined #zig
19:29
return0e has quit [Ping timeout: 256 seconds]
19:30
steveno_ has quit [Remote host closed the connection]
19:33
return0e has joined #zig
19:57
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
20:00
davr0s has joined #zig
20:36
Ichorio has quit [Ping timeout: 245 seconds]
21:41
darithorn_ has joined #zig
21:51
darithorn has joined #zig
21:53
quc has quit [Remote host closed the connection]
22:14
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
22:27
alandipert has quit [Remote host closed the connection]
22:29
alandipert has joined #zig
22:29
alandipert has quit [Client Quit]
22:30
alandipert has joined #zig