<fengb>
const foo = .{ .bar = 1}; // creates an anonymous struct with a bar field (will not match the Foo type)
<phillyiscool>
yeah, i know this part
<mikdusan>
phillyiscool: that's a common idiom. bring in the C lang stuff and sub-namespace it requiring 'c.whatever' for access. it can be any name you choose.
<phillyiscool>
mikdusan but c. isn't required for access, as shown above :)
<mikdusan>
c is required for the fn. from the fn, it then permits generic enum-literals for coercion
cren has quit [Ping timeout: 245 seconds]
<phillyiscool>
Yeah, that's where my expectations weren't met, I assumed I needed to use c. to access *anything* that the library provided, but apparently it's for functions but not for enums.
<mikdusan>
so your fn really wants: c.my_function(c.MyEnum.some_enum)
<mikdusan>
and zig lets you do `c.my_function(.some_enum)`
<fengb>
That rhymes!
<alexnask>
phillyiscool, This is not specific to C import stuff, .enum_literal will coerce to any enum type that has an `enum_literal` field
<mikdusan>
it's just sugar. fine tasting sugar, but just sugar
cole-h has joined #zig
<phillyiscool>
What's the non sugar version?
<alexnask>
hmm idk if I would call it sugar, it has its own type and can exist outside of typed contexts where it gets coerced to a specific enum type
<mikdusan>
c.my_function(c.MyEnum.some_enum)
<alexnask>
But it is tasty yeah :p
<fengb>
Salt
<fengb>
Syntax salt?
<phillyiscool>
mikdusan, I meant the non-sugar version of .CURLOPT_URL
<mikdusan>
sugar might be a bad choice of wording yeah
<mikdusan>
phillyiscool: are you able to see the zig generated import file?
<ifreund>
it's somewhere in zig-cache, in the o folder
<phillyiscool>
there are many files in the o folder
<ifreund>
should be called cimport.zig
<phillyiscool>
there are several subfolders with cimport.zig files
<phillyiscool>
maybe this is it: pub const CURLOPT_URL = @enumToInt(enum_unnamed_17.CURLOPT_URL);
<ifreund>
you can nuke the cache and rebuild to get rid of any stale files
<ifreund>
yeah so c.enum_unnamed_17.CURLOPT_URL is the sugar free version
<phillyiscool>
ah, ok
<fengb>
Why is it unnamed? That’s pretty fugly
<phillyiscool>
so you would never use the non-sugar version
<ifreund>
fengb: happens more than you would think in C code :P
<alexnask>
sugar-free is for losers /s
<fengb>
Oh right, enums are just a fancy way of doing globals
<mikdusan>
I _think_ the explicit version would be `c.curl_easy_setopt(curl, c.enum_unnamed_17.CURLOPT_URL, "http://example.com")`
<ifreund>
there are also lots of anon unions
<fengb>
How does the function take in an enum if it’s unnamed?
<mikdusan>
it is named. it's just named _unnamed :)
<alexnask>
Is it actually named _unnamed in the C source?
<fengb>
🤯
<ifreund>
probably thanks to the preprocessor
<mikdusan>
one day someone will post this cimport.zig so we stop guessing :)
<mikdusan>
phillyiscool: from there you can see zig knows that it must be type c.CURLoption . and that's how it knows to take a vanilla enum-literal `.anything` and coerce to c.CURLoption . if you used a `.bogus` it would give error
<phillyiscool>
yeah it's making a bit more sense now, thanks for your help
dimenus has joined #zig
torque has quit [Read error: Connection reset by peer]
drp_ has quit [Read error: Connection reset by peer]
<mikdusan>
anyone here have experience with interval trees?
<scientes>
mikdusan, you could store it as an entry in two red-black trees
<scientes>
as long as they are no duplicates
<scientes>
or a way to avoid duplicates with other data
<scientes>
yeah, interesting problem
<mikdusan>
that pages states `A naive approach might be to build two parallel trees... O(n) time` . my use case will have duplicates
<scientes>
...which is no better than brute-force.
<mikdusan>
i'm trying to figure out should I go with (augmented) interval tree or range tree
<scientes>
ahh yes
<companion_cube>
just use sqlite!™
<scientes>
more like sqheavy
<companion_cube>
?
<oats>
I really like zig's multi-line string syntax
<oats>
I think that most languages kinda half-ass this and let it screw up code formatting
<foobles>
yeah me too
<ifreund>
agree
<ikskuh>
oats: i just say C#-Multilines :D
<ikskuh>
horrible :D
<ifreund>
simple but elegant
<ikskuh>
@"""foobles"" is a nickname";
<oats>
oh yuck
<ikskuh>
yep
<ikskuh>
using "" as an escape for
<ikskuh>
"
<oats>
D:
<foobles>
it's funny, in kotlin they use triple quotes, so you get the indentation issues like a bunch of other langs. so in IntelliJ, if you type the """, it will automatically add a `.trimIndent()` to the end of the literall :P
<foobles>
thats the preferred way
<ikskuh>
i really love lua's way of using "multiline strings"
<foobles>
how are they different from other langs?
<ikskuh>
anything that starts with "[[" with any number of = gets a multiline string terminated by ]] with the same number of =
<ikskuh>
give me a sec
<oats>
ikskuh: but code formatting is still bleh :P
<alexnask>
Lol guess I should have checked the makefile :D
<alexnask>
I was wondering why it had build.zig and make :P
<pmwhite>
to be fair, I did tell you that `zig build` should work.
<pmwhite>
ifreund, that sounds like an improvement. I'll probably do that once this issue gets resolved.
slowtype1 is now known as slowtyper
drp has joined #zig
slowtyper has quit [Quit: WeeChat 2.8]
slowtyper has joined #zig
basedtho has quit [Quit: ZNC 1.6.5+deb1+deb9u2 - http://znc.in]
torque has joined #zig
<pixelherodev>
Whoa whoa whoa
<pixelherodev>
Working on one issue at a time?!
<pixelherodev>
... that actually sounds quite reasonable
<alexnask>
Okay I can repro now :D Time to find the bug
zenxhd has joined #zig
<alexnask>
pmwhite, I think this is the line that triggers it for some reason: const char_width = renderns.sourceCodeProAtlas.legend['X'].?.size[0];
<alexnask>
Yes it will just segfault in another file on the same line if you comment it out.. Time to find out why it triggers it so much :P
<pmwhite>
hmmm, interesting.
<pixelherodev>
Is there a way to tell zls that a function's casing is deliberate?
<pixelherodev>
"Doesn't match style" because I'm deliberately using two kinds of casing to differentiate two classes of operations
<andrewrk>
zls complaining about style is of questionable compliance with https://ziglang.org/documentation/master/#Style-Guide which says "These are general rules of thumb; if it makes sense to do something different, do what makes sense."
<alexnask>
Good point, we better add options :P
dnmllr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<andrewrk>
haha
<alexnask>
This is a weird bug
<alexnask>
some_global_arr[0], some_global_arr[1] <- fine, some_global_arr[2] <- crash at codegen
<alexnask>
some_global_arr is a [128]?T runtime value
<alexnask>
>.<
<pmwhite>
Hmm, I wonder where you saw that type.
<alexnask>
legend: [128]?Glyph,
<alexnask>
pmwhite, I have a workaround for you, `var X: usize = 'X';` and array access with [X]
<alexnask>
Ill try to repro in a small testcase and open an issue
<alexnask>
I cant even reap the beenefits of fixing compilation on wsl
<alexnask>
Feelsbadman
<pmwhite>
alexnask: just updated the three locations where I do that, but it still doesn't compile. Is it compiling for you?
<alexnask>
Yes
<alexnask>
I can ship you an elf executable as proof lol
<alexnask>
Make sure they are 'var'
<alexnask>
Im on master branch if that helps
<pmwhite>
Oh, I did const.
<nrdmn>
I'm having trouble building zig. It complains about symbols not being found. It seems like zig is not linked against libclang-cpp when it should be?
<alexnask>
I just want a screenshot as a reward pmwhite :D
<pixelherodev>
I'll patch the style thing in zls
<pixelherodev>
I noticed it, I should fix it :)
<nrdmn>
cmake says it can't find CLANG_LIBRARIES. When I pass -DCLANG_LIBRARIES=-lclang-cpp to cmake, it successfully links but then outputs ": CommandLine Error: Option 'mc-relax-all' registered more than once!"
<pixelherodev>
Linking against clang-cpp is a pain from what I remember
<pixelherodev>
I patched my Clang build to generate the many small libraries and linked against those, but I really wouldn't recommend it
<pixelherodev>
Someone can probably tell you the *correct* way to solve this
<andrewrk>
nrdmn, you have to link against everything statically because llvm, clang, and lld are not all provided dynamically by your package manager
_Vi has quit [Ping timeout: 244 seconds]
dddddd has joined #zig
alexnask has quit [Ping timeout: 256 seconds]
<nrdmn>
andrewrk: you mean with 'ZIG_STATIC_LLVM=ON'? because I don't have the static llvm libraries either
<andrewrk>
no, no configuration options on zig end's needed. your system package manager has not provided a set of libraries that are compatible with each other
<andrewrk>
you will have to compile from from source until such time as your system packages actually work
<fengb>
Will stage 2 offer an exclude-LLVM build option?
<pmwhite>
alexnask: I haven't found a screenshot program that actually works on Wayland.
<andrewrk>
fengb, yeah. other way around actually. -Denable-llvm
<fengb>
Ah cool
<pixelherodev>
THink I get the style thing working
<fengb>
I've made it a point to not play Gameboy games until it runs in my emulator. But there's so many I want to play now :(
<andrewrk>
I feel you on that
<fengb>
Oh right, you're still shaving that yak
<pixelherodev>
ZLS folks: there a place to send a patch? Or is GitHub PR the canonical way to send a patch?
<pixelherodev>
Got warn_style opt-in working
<pixelherodev>
I mean it was like ten lines but still :P
alexnask has joined #zig
<ifreund>
pmwhite: what compositor? grim + slurp has worked great for me on sway
<pixelherodev>
Same
<ifreund>
works on river too :D
<pixelherodev>
grim + slurp = :heart:
<alexnask>
pixelherodev, Github PR if that is fine with you
* pixelherodev
shrugs
<pixelherodev>
I don't exactly like GitHub, but it's not going to kill me to send a PR lol
pystub has joined #zig
foobles has quit [Remote host closed the connection]
Snetry has quit [Quit: left Freenode]
Snetry has joined #zig
bren077s has quit [Quit: -a- Connection Timed Out]
<wilsonk>
traviss: just updated zig from git two minutes ago and built it, then updated and built zls. All went fine. Installed zls-vscode-1.0.0.vsix and it seems to be picked up by vscode as the hover functionality in settings.json states that the option 'zigLanguageClient.path' is the 'path to the zls exe' but zls still doesn't work. It doesn't even syntax highlight a zig file which I would assume would work with no config at all. Not sure what is
<wilsonk>
traviss: all I have running for extensions is zls and vim.
<traviss>
wilsonk, syntax highlighting is provided by a separate 'zig' extension by tiehuis. i found it by just searching for 'zig'.
<alexnask>
wilsonk, zls is a lnaguage server it doesnt do highlighting. You should install vscode-zig for that
<alexnask>
Just search for 'zig' by Marc Tiehuis
<wilsonk>
ok, or I assume I can use anderfr's? Or does it matter?
<alexnask>
I think this one is the most up to date extention but suit yourself
_Vi has joined #zig
<traviss>
did you add an entry to settings.json `"zigLanguageClient.path": "/path/to/zls/zig-cache/bin/zls"`
<alexnask>
^
<wilsonk>
Oh, nope I think Marc's is required because that just fixed everything. The 'path to zls' also needs to include zls as the executable...so not really just the path to where it is but what it's name is also in the string
<alexnask>
Yes you need the exe
<alexnask>
Also for an optimal experience I would suggest making a zls.json ile next to the executable
<alexnask>
And adding { "zig_std_path": "/path/to/zig/lib/zig" }
<wilsonk>
Can you specify these couple things on the github so that others don't run into these same problems? Please ;)
<alexnask>
(this is needed to resolve std library imports)
<wilsonk>
Yeah, I have the json file there...I thought I should make one up just in case it was needed for the plugin to run. I could tell from the code that there were defaults...but just thought I would do it anyways
<traviss>
any luck wilsonk? are you seeing completions from the std lib?
<wilsonk>
Looks all good now. Best part is that completions for the std lib work! That was the biggest part missing in metaleap's lsp. The best part about his, that is missing from zls is the hover hints over variables. I can see that you all have the hints for completion...just not the hover part yet
<wilsonk>
That is IMO, of course :)
slurpie has quit [Ping timeout: 260 seconds]
<traviss>
ok good. :) yeah i agree that hovers and jump to reference would be really nice to haves. big thanks to superaguste and alexnask. nice work guys.
<alexnask>
Yes we have lots of work to do
<wilsonk>
yeah, std lib completions with the code view and doc view for variables is a huge bonus! Works great, thanks guys!
<alexnask>
Cheers, glad you like it. Please keep a mind to zig pr #5353 and recompile when it is merged if you can
<alexnask>
There is a bug in the zig parser that can cause it to infinite loop, although its a pretty hard type to make (`arr: 100]u8,` in a struct)
<alexnask>
typo*
<wilsonk>
ah, ok
<alexnask>
keep an eye on*
<alexnask>
So many typos >_>
joey152 has joined #zig
bren077s has quit [Read error: Connection reset by peer]
bren077s has joined #zig
<GreaseMonkey>
daurnimator: wrt your PR for deflate-for-zig (sorry it's taken so long for me to get back to this), the @intCast()s in block_tree.zig are more or less required right now unless we change the base type in readBitsNoEof (i get integer overflows otherwise), would you rather leave the types in or chagne the base type used for readBitsNoEof?
Akuli has quit [Quit: Leaving]
<ikskuh>
hey, short question: why does i386-baseline emit sse instructions?
<mikdusan>
p3 was first to support SSE
<ikskuh>
hm
<mikdusan>
not a reason but just to give idea it goes back quite a ways
<ikskuh>
so i have to use baseline-sse-see2 for kernels?
<ikskuh>
which seems to work
<fengb>
The default CPU for i386 is Pentium 4 for some reason
<GreaseMonkey>
to be honest Zig is one of the few languages where the code often fits into 640KB of RAM
<nephele>
I am looking forward to use zig in the fuuuture to build something fun for my ibm personal computer, but that has "only" 512KB :)
<mikdusan>
I'll give you $5.12 for it's keyboard
<ikskuh>
mikdusan: remove the point and i'll send you one
slice has quit [Quit: zzz]
Pursche01 has quit [Quit: Connection closed for inactivity]
curtisf has joined #zig
metaleap has quit [Quit: Leaving]
slowtyper has quit [Ping timeout: 256 seconds]
alexnask has quit [Quit: Leaving]
FireFox317 has quit [Ping timeout: 246 seconds]
slurpie has joined #zig
dermetfan has quit [Ping timeout: 260 seconds]
curtisf has quit [Remote host closed the connection]
<stripedpajamas>
trying to figure out how to save the hex representation of a []u8 into a var. is (fmt, args) => []const u8 in the std library somewhere ?
<ikskuh>
std.fmt.bufPrint
<stripedpajamas>
thanks!
slice has joined #zig
<mikdusan>
fengb: can you look at #3937? would you say `var vec : @Vector(4, f32) = src[0..4].*;` is correct and this issue can be closed?
<oats>
is there anything equivalent to sscanf in the stdlib?
ifreund has quit [Ping timeout: 240 seconds]
<oats>
stripedpajamas: there's also fmt.allocPrint if you want to allocate instead