ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
davr0s has quit [Client Quit]
davr0s has joined #zig
davr0s has quit [Client Quit]
porky11 has quit [Quit: Leaving]
ducktype has joined #zig
<ducktype>
hi
<ducktype>
error: expected error union type, found '?NextError![]u8'
<ducktype>
how to use try and typeinference with union and nullable oprional return?
<ducktype>
var first_arg = try args.next(allocator);
ducktype has quit [Quit: Page closed]
errpr has quit [Quit: Leaving]
jjido has quit [Remote host closed the connection]
Zaab1t has joined #zig
Zaabtop has joined #zig
Zaab1t has quit [Ping timeout: 268 seconds]
Zaabtop is now known as Zaab1t
Zaab1t has quit [Ping timeout: 268 seconds]
porky11 has joined #zig
davr0s has joined #zig
Zaab1t has joined #zig
very-mediocre has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
Zaab1t has quit [Quit: bye bye friends]
steveno has joined #zig
Zaab1t has joined #zig
hio has joined #zig
qazo has quit [Ping timeout: 244 seconds]
steveno_ has joined #zig
steveno has quit [Ping timeout: 268 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
steveno_ has quit [Quit: Leaving]
davr0s has joined #zig
qazo has joined #zig
Sahnvour has joined #zig
porky11 has quit [Read error: No route to host]
Zaab1t has quit [Quit: bye bye friends]
hio has quit []
Zaab1t has joined #zig
porky11 has joined #zig
fsateler has quit [Ping timeout: 240 seconds]
fsateler has joined #zig
fsateler has quit [Read error: Connection reset by peer]
ducktype has joined #zig
<ducktype>
hi
<ducktype>
how to pass a null pointer to syscalls? which is the sytntax for a literal null pointer?
fsateler has joined #zig
<ducktype>
found: @intToPtr([*]const u8,0)
<ducktype>
a quick way to convert ArgIterator to []const []const u8 ?
<andrewrk>
ducktype, sounds like you want std.os.argsAlloc() rather than the iterator API
<ducktype>
ty better
dtz has quit [Remote host closed the connection]
<andrewrk>
ducktype, you can use `null` for pointers when your pointer type has a ? in front of it
<andrewrk>
if a function can accept a null pointer then the pointer type should be, e.g. ptr: ?[*]const u8
<andrewrk>
and you can use @ptrToInt(ptr) on that type, and it will give you 0
<ducktype>
so most of pub fn mount(special: [*]const u8, dir: [*]const u8, fstype: [*]const u8, flags: u32, data: usize) usize { this arguments in the signature should be optional i think
<andrewrk>
that sounds correct
<andrewrk>
ducktype, are you referring to this? "An existing mount may be remounted by specifying MS_REMOUNT... The source and filesystemtype arguments are ignored."
dtz has joined #zig
<andrewrk>
if an argument is sometimes ignored, but otherwise should be a valid pointer, then it is still best to leave it as non-optional. and then when the argument would be ignored, pass `undefined`
<ducktype>
i'm checking with strace to see that the unshare and mount commands in util-linux do
<ducktype>
and aften nulls are passed along
<ducktype>
there are many cases
<ducktype>
i think
<andrewrk>
if the only values that can be passed are valid pointers and sometimes the value is ignored, then undefined is your friend
<ducktype>
i'm not sure how much the kernel ignores these args, and because i'm not getting the same result and unshare/mount commands i'm betting on this, i want to do exactly the same call they are doing
<ducktype>
the same results AS unshare/mount commands
<andrewrk>
in this case, I agree, these arguments should be optional
<andrewrk>
I suggest to file an issue, or send a patch, and then in the meantime use a workaround of copy-pasting the function into your own project, and editing the signature
<ducktype>
:)
<ducktype>
var exec_argv = []const []const u8 {shell}; //exec_argvs becomes of type [1][]const u8
<ducktype>
but i want exec_argv to be a "generic" [][] u8
<ducktype>
it's good? how to do that? i'm confused
<andrewrk>
it's an array and you want a slice, so you need to either slice it, or take the address of it
very-mediocre has quit [Ping timeout: 256 seconds]
<ducktype>
i want to initialize some default arguments, but if someone passed to my program something i will replace with my current args excluding the first