ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
martinium has joined #zig
<martinium>
Happy Friday fellow ziggers
clownpriest has quit [Ping timeout: 245 seconds]
clownpriest has joined #zig
<andrewrk>
Hi martinium
<andrewrk>
How's your project going?
<scientes>
llvm-ir with slices is really verbose
dbandstra has joined #zig
kristate has joined #zig
kristate has quit [Ping timeout: 252 seconds]
kristate has joined #zig
<dbandstra>
unique_id, when playing oxid did the framerate ever start to get sluggish for you at random times?
<dbandstra>
i don't really know why it happens, i did a bit of profiling and it should be able to run at like 10,000 fps
<dbandstra>
maybe sdl_mixer is doing something funny i dunno
kristate has quit [Remote host closed the connection]
kristate has joined #zig
_whitelogger has joined #zig
kristate has quit [Read error: Connection reset by peer]
<unique_id>
dbandstra: I don't think so. The only issue I have is if I move the window I lose the ability to control the character for a while. But this is Linux+i3, so who knows what's happening.
<unique_id>
Well, I lose all ability to send input to the program (just to make that clear). But the framerate looks fine. This is some i3/X11 issue I bet.
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
kristate_ has joined #zig
kristate has quit [Ping timeout: 272 seconds]
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<unique_id>
Question. I need to have "worker threads" read from a global boolean to know when to shut down. They should not read the variable from a register. I don't remember the C++ discussion about when to use volatile but for C++ it or atomic would be the options.
<unique_id>
What do I do in Zig?
<andrewrk>
unique_id, atomics
unique_id has quit [Remote host closed the connection]
unique_id has joined #zig
davr0s has joined #zig
<unique_id>
My worker threads need a pointer to my TaskManager. That means my TaskManager can't be moved around. Also for now I can't initialize my worker threads inside TaskManager.init. Hmm. Maybe init returns pointer to a heap allocated TaskManager? Maybe that's the most sound design. Best way to make TaskManager non-movable.
<scientes>
you generally should not pass stack variables between threads
<MajorLag>
that should fail, you're returning a slice of the stack that will be invalid when the function returns.
<scientes>
oh my bad
<MajorLag>
though in practice it will sometimes work because that portion of the stack, though invalid, isn't overwritten yet.
<scientes>
mem.toSliceConst does that
<scientes>
thats the bug i was looking at
<MajorLag>
mem.toSliceConst returns a slice of data that it was passed a pointer to, that's legit.
<MajorLag>
slices are a kind of pointer.
<MajorLag>
they don't tehmselves contain data.
<scientes>
pointer and length
<MajorLag>
yeah. in old parlance this would have been called a "fat" pointer.
<andrewrk>
every pointer in zig has the concept of "how many"
<andrewrk>
pointer to array: compile-time known how many
<andrewrk>
slice: runtime known how many
<andrewrk>
[*]: unknown how many
<andrewrk>
*: exactly one
<andrewrk>
and soon we will have [*]null: how many is determined by a final null / 0
<andrewrk>
*[1]T and *T can implicitly cast to each other since they represent the same thing
clownpriest has joined #zig
clownpriest has quit [Ping timeout: 250 seconds]
<MajorLag>
andrewrk, are `[]null` and `[N]null` still planned to be a thing? Because it occurs to me that unicode strings will not function as expected if the compiler does things like implicitly casting `[]null u8` to `[]const u8`.
<MajorLag>
unicode in this case being UTF-16 or 32.
clownpriest has joined #zig
<andrewrk>
MajorLag, yeah those are still planned. hmm let me consider
<andrewrk>
window's "wide string" would be [*]null u16
<andrewrk>
this is a pointer to array of u16s with length determined by a sentinel u16 that is 0
<MajorLag>
So the rule will be that you have to cast []null u8 to the appropriate integer type, which makes sense to me so far.
<andrewrk>
what's the problematic use case?
<scientes>
ok, arm64 patches ready for review, just got vdso working
<MajorLag>
there wouldn't be one in that case. I was thinking UTF-16 would be `[]null u8`, which would cause the problem.
unique_id has quit [Remote host closed the connection]
<andrewrk>
scientes, congrats! I'll have a look in a bit
<MajorLag>
But since you know you're working with UTF-16, it isn't unreasonable to expect you to use `[]null u16`.
<scientes>
also, musl's arm64 vdso code is broken
<andrewrk>
MajorLag, so if you represent UTF-16 as bytes, this would be equivalent to representing an arbitrary file as bytes - in both cases null termination is the incorrect way to determine the length, and normal slices should be used instead
<MajorLag>
right, makes sense.
<andrewrk>
scientes, #musl is really friendly, I recommend mentioning your findings there
clownpri1 has joined #zig
clownpriest has quit [Ping timeout: 240 seconds]
clownpri1 has quit [Ping timeout: 240 seconds]
clownpri1 has joined #zig
unique_id has joined #zig
<unique_id>
If anyone is maintaining a list of cIncludes that lead to issues: when using pthread_cond_t from pthread.h I get the error: compiler bug @cImport generated invalid zig code
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<unique_id>
"Each architecture must define the following macros..." __SIZEOF_PTHREAD_MUTEX_T
<unique_id>
..ok
<unique_id>
So the size isn't available in the header? It doesn't seem so. I'll just make it something huge.
<andrewrk>
unique_id, __SIZEOF_PTHREAD_MUTEX_T is probably in a macro that zig doesn't (or can't) support
<andrewrk>
we essentially have to parse the C code ourselves to try to translate a macro, and some concepts are inherently impossible to represent soundly in zig
<andrewrk>
unique_id, hm this looks like a simple integer. it should work
<unique_id>
it was pthread_cond_init that failed
<unique_id>
I was just trying to find the size of pthread_cond_t and pthread_mutex_t
<unique_id>
because you do have to store them by value. So I just made them 64 byte large
<andrewrk>
I backported some zig std lib code to stage1 and made this mistake
<Barabas>
I'll try it out.
<Barabas>
(ClCompile target) -> E:\Zig\src\os.cpp(509): error C2679: binary '=': no operator found which takes a right-hand operand of type 'initializer list' (or there is no acceptable conversion) [E:\Zig\build-release\zig.vcxproj]
<Barabas>
Just trying to get back to do some zig programming after my holiday ^^
<Barabas>
It says the build failed, but at least I can run the unit tests for my code
clownpriest has quit [Ping timeout: 252 seconds]
kristate has joined #zig
kristate has quit [Ping timeout: 272 seconds]
hoppetosse has joined #zig
hoppetosse has quit [Ping timeout: 245 seconds]
reductum has joined #zig
clownpriest has joined #zig
_whitelogger has joined #zig
dbandstra has joined #zig
Angr1st has joined #zig
<Angr1st>
Hello everyone the documentation for building zig from source on windows states "Visual Studio 2015" as requirement. Has anyone tried building it with the newest version (Visual Studio 2017 15.8.3)?
<dbandstra>
i tried vs2017 and it didn't work
<Angr1st>
well fair enough going to install visual studio 2015 then
<dbandstra>
oh wait
<dbandstra>
i wasn't trying to build zig, i think i downloaded the binary and tried to use it, but it was getting SDK related errors
<dbandstra>
andrew said "I haven't tried to support vs2017 yet since last time I tried to build llvm it didn't work. might be time to try again "
<Angr1st>
Ok I will just try it and if it does not work I will go with the way shown in the wiki
clownpriest has quit [Quit: clownpriest]
<Angr1st>
I did a quick google search an It seems like llvm needs msbuild targets only shipped with vs2015 v140 and vs2017 only ships with v141 by default. You can use the visual studio installer to add the v140.
clownpriest has joined #zig
<Angr1st>
to vs2017 though
rain2 has quit [Quit: WeeChat 1.9.1]
mnoronha has joined #zig
martinium has joined #zig
Barabas has quit [Ping timeout: 252 seconds]
mnoronha has quit [Ping timeout: 246 seconds]
<Angr1st>
So building it worked using vs2017 (Using the vs2017 installer I also installed CMake) but I think the test are not run using the command shown in the wiki 'bin\zig.exe build --build-file ..\build.zig test'. Can someone tell me how to run the test?
<dbandstra>
what output did you get from running that?
<dbandstra>
works for me in linux
<Angr1st>
Invalid argument: --build-file
<Angr1st>
Usage: .\bin\zig.exe [command] [options] Commands: build build project from build.zig build-exe [source] create executable from source or object files build-lib [source] create library from source or object files build-obj [source] create object from source or assembly builtin show the source code of that @import("builtin") run [source] cr
<dbandstra>
did you copy that exact command? zig build --buildfile
<Angr1st>
so it outputs the help of zig.exe after showing 'Invalid argument: --build-file'
<dbandstra>
--build-file*
<dbandstra>
i get that output if i forget the `build` in the middle
<Angr1st>
well it seems like I was just not good enough at using copy and paste
<Angr1st>
but now I get ' error: unable to find 'builtin.zig' const builtin = @import("builtin"); ^'
<Angr1st>
followed by "error: expected type 'noreturn', found 'void' pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {"
dbandstra has quit [Ping timeout: 252 seconds]
reductum has quit [Quit: WeeChat 2.2]
dbandstra has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<dbandstra>
i'm not sure about that
kristate has joined #zig
mahmudov has quit [Remote host closed the connection]
kristate has quit [Remote host closed the connection]