ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
rzezeski has quit [Read error: Connection reset by peer]
karrick has quit [Read error: Connection reset by peer]
tracernz has quit [Read error: Connection reset by peer]
procnto has quit [Write error: Connection reset by peer]
karrick has joined #zig
rzezeski has joined #zig
procnto has joined #zig
tracernz has joined #zig
<fengb> jaredmm: had some design issues at the time, mostly not being able to generate structs at comptime
<fengb> I also wanted arbitrary field metadata to smooth out the auto serialization
<fengb> And in the end... I didn’t really need it so I left it to rot
ur5us has quit [Ping timeout: 264 seconds]
<frmdstryr> Is there a way to make a vector of const u8 somehow? `const v = @as(@Vector(4, u8), "find");` does not work
<ifreund> try `const v = @as(@Vector(4, u8), "find".*);`
CodeSpelunker has joined #zig
<Biolunar> I’d like to share some code between my projects. Are there pure zig libraries yet or only C compatible libs?
<frmdstryr> ifreund: That works, thanks!
<fengb> Zig libraries are by source only atm. Not sure if defining a Zig ABI is being planned
<frmdstryr> ifreund: What about with a comptime known slice? Eg if I have `comptime vec: []const u8` , then somehow get a `const v = @as(@Vector(vec.len, u8), vec);`
<ifreund> this might work: @as(@Vector(vec.len, u8), vec[0..vec.len].*);
<ifreund> your goal is to get an array of the length you want the vector to be
<ifreund> "foo".* has type [3:0]u8 for example
<Biolunar> fengb: alright, thx
<frmdstryr> sweet, yes that works
ur5us has joined #zig
squeek502 has joined #zig
CodeSpelunker has quit [Quit: CodeSpelunker]
a92 has joined #zig
earnestly has quit [Ping timeout: 258 seconds]
cole-h has quit [Ping timeout: 260 seconds]
NoName91 has joined #zig
aerona has joined #zig
kristoff_it1 has quit [Ping timeout: 256 seconds]
a92 has quit [Quit: My presence will now cease]
kristoff_it1 has joined #zig
NoName91 has quit [Remote host closed the connection]
dddddd has quit [Ping timeout: 268 seconds]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
marnix has quit [Ping timeout: 260 seconds]
marnix has joined #zig
dddddd has joined #zig
virkony has quit [Ping timeout: 272 seconds]
frmdstryr has quit [Ping timeout: 240 seconds]
swills has quit [Ping timeout: 240 seconds]
swills has joined #zig
earnestly has joined #zig
xackus_ has joined #zig
xackus has quit [Ping timeout: 240 seconds]
lucid_0x80 has joined #zig
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 246 seconds]
casaca has quit [Remote host closed the connection]
casaca has joined #zig
a_chou has joined #zig
casaca has quit [Remote host closed the connection]
casaca has joined #zig
casaca has quit [Remote host closed the connection]
casaca has joined #zig
a_chou has quit [Quit: a_chou]
ur5us has quit [Ping timeout: 264 seconds]
x2C25 has quit [Ping timeout: 240 seconds]
aerona has quit [Quit: Leaving]
dumenci has quit [Ping timeout: 265 seconds]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
osa1 has joined #zig
swills has quit [Ping timeout: 258 seconds]
swills has joined #zig
frett27 has joined #zig
kristoff_it1 has quit [Ping timeout: 260 seconds]
GrooveStomp has quit [Ping timeout: 265 seconds]
squeek502 has quit [Remote host closed the connection]
mmohammadi9812 has quit [Read error: Connection reset by peer]
mmohammadi9812 has joined #zig
earnestly has quit [Ping timeout: 265 seconds]
cole-h has joined #zig
riba has joined #zig
virkony has joined #zig
xackus has joined #zig
mmohammadi9812 has quit [Ping timeout: 240 seconds]
xackus_ has quit [Ping timeout: 246 seconds]
mmohammadi9812 has joined #zig
frett27 has quit [Ping timeout: 260 seconds]
riba has quit [Ping timeout: 246 seconds]
cole-h has quit [Ping timeout: 264 seconds]
pfg_ has quit [Quit: Leaving]
x2C25 has joined #zig
return0e[m] has quit [Quit: Idle for 30+ days]
skuzzymiglet has joined #zig
_whitelogger has joined #zig
FireFox317 has joined #zig
earnestly has joined #zig
Yardanico has quit [Ping timeout: 272 seconds]
Yardanico has joined #zig
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
supercoven has joined #zig
<sjums> How do I call functions in a DLL on windows?
<sjums> I've managed to create a .lib file from said dll. But as soon as I try to declare and call any extern functions the program just exists immediately
mmohammadi9812 has quit [Ping timeout: 260 seconds]
mmohammadi9812 has joined #zig
decentpenguin has quit [Ping timeout: 260 seconds]
<ifreund> Unfortuneatly I'm not at all familiar with windows, how are you linking your zig program against the dll?
supercoven_ has joined #zig
supercoven_ has quit [Max SendQ exceeded]
supercoven_ has joined #zig
supercoven_ has quit [Max SendQ exceeded]
supercoven_ has joined #zig
supercoven_ has quit [Max SendQ exceeded]
supercoven_ has joined #zig
supercoven_ has quit [Max SendQ exceeded]
supercoven_ has joined #zig
supercoven_ has quit [Max SendQ exceeded]
supercoven has quit [K-Lined]
<sjums> For building I'm simply executing `zig build-exe .\main.zig --verbose-link`. In main.zig I have a `pub extern "wpcap" ...` declaration and from the --verbose-link output I can see the wpcap.lib file (residing in same dir as main.zig) is included in the linking process.
<sjums> added to that, I also call the declared extern function, or else it's not included
<sjums> (trying to use the pcap library, btw)
<ifreund> what if you do `zig build-exe main.zig wpcap.lib`
<sjums> Then wpcap.lib is included twice in the linker output
<sjums> that gives no errors and no warnings
<ifreund> for your extern declarations, you don't need to make them pub and if you leave out the "wpcap" string it won't limit the search
<ifreund> I'd try just extern fn foobar();
<sjums> Now I (obviously?) have to add the wpcap.lib as an argument when building. Same behaviour, though.
<ifreund> hrm, don't think I can be of much help then sadly, hopefully a windows user stops by
<sjums> No probs. Appreciate it anyway :) Does this look right, though? https://zero.hurtig.ninja/?8dba440363071fd7#5t5kvIwcs1fOgxbz5L6JLcQE1RWOqgZEQutR5wUp9GY=
<sjums> pcap_lib_version returns a pointer to a string
<ifreund> no, that should probably be a [*:0]u8 or [*:0]const u8
<ifreund> strings in C are null terminated pointers to char or const char
<ifreund> char is equivalent to u8 in zig
<ifreund> also extern implies callconv(.C) but that shouldn't cause any issues
<sjums> I initially got inspiration from kernel32.zig where the callconv is Stdcall
<sjums> So I left it there (:
<sjums> I had it as a usize since that's what's most equivalent to a "generic pointer" in bits.zig. I thought when a function returned a pointer to a string, you'd get a pointer and not the pointed to string?
<ifreund> [*:0]u8 is a pointer to a 0-terminated series of u8s
lucid_0x80 has joined #zig
<ifreund> usize should have the same abi though
<ifreund> but yeah, pcap_lib_version() returns a [*:0]const u8
<alexnask[m]> You should do `extern "wpcap" fn pcap_lib_version() callconv(.C) usize;`
<alexnask[m]> I think
<ifreund> really? what am I missing about windows?
<sjums> ifreund, no need to do unsafe things when safe alternatives exists ;)
<sjums> alexnask[m], that's exactly where I started :p
<alexnask[m]> Oh sorry mostly talking about the string thing after extern, not usize vs the pointer
<sjums> Odd thing is that everything compiles, links and executes with no exceptions nor warnings. But the main method is never reached
<ifreund> what happens if you run it in a debugger?
<sjums> just broke open the main.exe in a dissasembler. execution never leaves the ntdll module. Not sure why though
<alexnask[m]> huh
<sjums> reversing is not my greatest talent
<ifreund> you may want to have a look at std/start.zig to see the code that runs before your main is called
lucid_0x80 has quit [Ping timeout: 246 seconds]
<sjums> in my dissasembler start.zig code is part of my main.exe module, which is never called into. I have a breakpoint at the start.zig entrypoint which is never hit
<sjums> I'm pretty sure I'm doing something really wrong!
<ifreund> weird
<alexnask[m]> Can you add `--library wcap` to your command line (and possibly a lib dir)?
<alexnask[m]> Not sure if this will make a difference, I assume the current CLI will take the .lib file from the build-exe command and link against it anyway
<sjums> alexnask[m], Code: https://zero.hurtig.ninja/?21e47aa76ca76777#fVECRB+9V+LmE6ogC6GcWmjaRzlitc3kaoOVpK1XtT4=
<sjums> So wpcap should be linked
<alexnask[m]> yeah this looks correct
<sjums> gotta grab some lunch
<sjums> bbl
znowflak3[m] has joined #zig
x2C25 has quit [Ping timeout: 260 seconds]
<g-w1> I have noticed this interesting pattern where for example Inst is just a struct with a tag that belongs to another struct. Then one can use the tag they find on inst and feildParentPtr to get the whole thing. Is this pattern common, and what is the benefit over just using union(enum). https://github.com/ziglang/zig/blob/master/src/astgen.zig#L2597 here is an example where just the Inst is returned with the tag
<g-w1> and src
<alexnask[m]> union(enum) will have sizeOf ~= sizeOf(TagType) + sizeOf(biggest payload)
<ifreund> well if the "child" structs aren't all the same size you save memory
<g-w1> ah that makes sense, i was confused when i first saw this because no other langs have this
<dominikh> is there a valid, builtin and concise way of doing something like this? http://sprunge.us/DnMxao – that is, an easy way of getting the type of a field, given the struct type itself. or do I have to write my own function and use @typeInfo?
<alexnask[m]> Well, this is essentially the same as doing `struct Child { Base base; more_data data; }` in C and casting from `Base*` to some child type pointer
<alexnask[m]> aka hand-rolled inheritance
<alexnask[m]> dominikh: std.meta.fieldInfo(Foo, "foo_field").field_type
<dominikh> alexnask[m]: thank you
<g-w1> alexnask[m] thanks. i didn't know about this type of pattern
frmdstryr has joined #zig
FireFox317 has quit [Ping timeout: 260 seconds]
Kingsquee has quit []
nvmd has joined #zig
waffle_ethics has joined #zig
frmdstryr has quit [Ping timeout: 240 seconds]
frmdstryr has joined #zig
gazler has joined #zig
kristoff_it1 has joined #zig
waffle_ethics has quit [Ping timeout: 246 seconds]
waffle_ethics has joined #zig
tane has quit [Quit: Leaving]
DarkUranium has quit [Read error: Connection reset by peer]
DarkUranium has joined #zig
DarkUranium has quit [Read error: Connection reset by peer]
DarkUranium has joined #zig
waffle_ethics has quit [Ping timeout: 264 seconds]
waffle_ethics has joined #zig
decentpenguin has joined #zig
omglasers2 has joined #zig
mmohammadi9812 has quit [Ping timeout: 256 seconds]
mmohammadi9812 has joined #zig
donniewest has joined #zig
czak has joined #zig
czak has left #zig [#zig]
lucid_0x80 has joined #zig
nvmd has quit [Quit: Later nerds.]
nvmd has joined #zig
lucid_0x80 has quit [Ping timeout: 260 seconds]
skuzzymiglet has quit [Ping timeout: 265 seconds]
Bastian[m] has quit [Quit: Idle for 30+ days]
lucid_0x80 has joined #zig
dbohdan has quit [Ping timeout: 272 seconds]
dbohdan has joined #zig
g-w1 has quit [Ping timeout: 264 seconds]
tane has joined #zig
g-w1 has joined #zig
Snetry- has joined #zig
Snetry has quit [Ping timeout: 268 seconds]
cole-h has joined #zig
Snetry- has quit [Ping timeout: 260 seconds]
GrooveStomp has joined #zig
Snetry has joined #zig
waffle_ethics has quit [Ping timeout: 265 seconds]
waffle_ethics has joined #zig
marnix has quit [Ping timeout: 256 seconds]
marnix has joined #zig
CodeSpelunker has joined #zig
hnOsmium0001 has joined #zig
osa1 has quit [Remote host closed the connection]
marnix has quit [Ping timeout: 260 seconds]
marler8997__ has left #zig ["Leaving"]
marler8997__ has joined #zig
waffle_ethics has quit [Ping timeout: 260 seconds]
frett27 has joined #zig
waffle_ethics has joined #zig
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 246 seconds]
x2C25 has joined #zig
dumenci has quit [Ping timeout: 272 seconds]
Akuli has joined #zig
CodeSpelunker has quit [Quit: CodeSpelunker]
skuzzymiglet has joined #zig
wootehfoot has joined #zig
frett27 has quit [Ping timeout: 265 seconds]
frmdstryr has quit [Ping timeout: 256 seconds]
frmdstryr has joined #zig
frett27 has joined #zig
marnix has joined #zig
Kena has joined #zig
mmohammadi9812 has quit [Ping timeout: 265 seconds]
<Kena> Please, where can I find the implementation of the function fn endian(Arch) Endian` but I don't find it in https://github.com/ziglang/zig/blob/master/lib/std/builtin.zig . I would like to test it against my own machine to know my CPU's endianess .
<ifreund> Kena: std/target.zig
<Kena> because using `Target.current.cpu.arch` is noted as deprecated
<Kena> Yes found it, thank you ifreund and alexnask[m]
mmohammadi9812 has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
mo_al has joined #zig
<andrewrk> Kena, where do you see `Target.current.cpu.arch` is noted as deprecated?
mo_al has quit [Remote host closed the connection]
marnix has quit [Ping timeout: 258 seconds]
<dutchie> i see a whole bunch of std code using ArrayList.span. is that worth going through and updating to be .items instead or is that something that zig fmt would update?
marnix has joined #zig
<ikskuh> zig fmt will only update syntax changes
<ikskuh> stdlib changes won't be updated
jmiven has quit [Quit: reboot]
jmiven has joined #zig
Xavi92 has joined #zig
ur5us has joined #zig
marnix has quit [Remote host closed the connection]
marnix has joined #zig
waffle_ethics has quit [Ping timeout: 246 seconds]
frett27 has quit [Ping timeout: 265 seconds]
omglasers2 has quit [Read error: Connection reset by peer]
marnix has quit [Ping timeout: 256 seconds]
tane has quit [Quit: Leaving]
Xavi92 has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
<Kena> andrewrk, at https://ziglang.org/documentation/master/#Compile-Variables it is indicated the following: /// Deprecatedpub const endian = Target.current.cpu.arch.endian();
<ifreund> Kena: I believe the re-export of Target.current.cpu.arch.endian(); as builtin.endian is what is deprecated here
<ifreund> not Target.current.cpu.arch.endian() itself
<Kena> Allright buddy, sorry for the inconvenience.
ur5us has quit [Remote host closed the connection]
ur5us has joined #zig
wootehfoot has quit [Quit: Leaving]
skuzzymiglet has quit [Ping timeout: 264 seconds]
Akuli has quit [Quit: Leaving]
Kena has quit [Remote host closed the connection]
donniewest has quit [Quit: WeeChat 2.9]
Kingsquee has joined #zig
nvmd has quit [Ping timeout: 265 seconds]
ur5us has quit [Ping timeout: 264 seconds]
mmohammadi9812 has quit [Ping timeout: 256 seconds]
mmohammadi9812 has joined #zig
ur5us has joined #zig