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/
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
MajorLag has joined #zig
tgschultz has quit [Ping timeout: 245 seconds]
MajorLag has quit [Ping timeout: 252 seconds]
moo has quit [Read error: Connection reset by peer]
tgschultz has joined #zig
schme245 has joined #zig
schme245 has quit [Ping timeout: 245 seconds]
jevinskie has joined #zig
<mikdusan> andrewrk: can u point me to a summary of issue with mtime; i’m assuming it relates to dependencies and saved hashes?
shawn_ has quit [Remote host closed the connection]
jevinskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
scientes has joined #zig
jevinskie has joined #zig
<andrewrk> emekankurumeh[m], mingw?
<andrewrk> mikdusan, I'll type up an issue for it tomorrow (and then solve it right away)
marmotini_ has joined #zig
scientes has quit [Remote host closed the connection]
marmotini_ has quit [Ping timeout: 250 seconds]
scientes has joined #zig
scientes has quit [Remote host closed the connection]
scientes has joined #zig
scientes has quit [Read error: Connection reset by peer]
shawn_ has joined #zig
<emekankurumeh[m]> andrewrk, yeah
marmotini_ has joined #zig
shawn_ has quit [Ping timeout: 246 seconds]
_whitelogger has joined #zig
_whitelogger has joined #zig
_whitelogger has joined #zig
dewf has quit [Quit: Leaving]
_whitelogger has joined #zig
marmotini_ has quit [Ping timeout: 245 seconds]
marmotini_ has joined #zig
nbjoerg_ has joined #zig
dch has quit [*.net *.split]
daurnimator[m] has quit [*.net *.split]
nbjoerg has quit [*.net *.split]
kristate_ has quit [Ping timeout: 255 seconds]
schme245 has joined #zig
schme245 has quit [Remote host closed the connection]
very-mediocre has joined #zig
schme245 has joined #zig
schme245 has quit [Ping timeout: 250 seconds]
schme245 has joined #zig
marmotini_ has quit [Ping timeout: 244 seconds]
very-mediocre has quit [Ping timeout: 256 seconds]
dewf has joined #zig
SimonNa has quit [Remote host closed the connection]
SimonNa has joined #zig
schme245 has quit [Ping timeout: 244 seconds]
jjido has joined #zig
return0e_ has joined #zig
return0e has quit [Ping timeout: 268 seconds]
jevinskie has quit [Read error: Connection reset by peer]
jevinskie has joined #zig
marmotini_ has joined #zig
brakmic has joined #zig
Zaab1t has joined #zig
Ichorio has joined #zig
schme245 has joined #zig
dch has joined #zig
schme245 has quit [Ping timeout: 240 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gamester has quit [Quit: Leaving]
_whitelogger has joined #zig
_whitelogger has joined #zig
dewf has quit [Quit: Leaving]
SimonNa has quit [Remote host closed the connection]
bheads has quit [Ping timeout: 255 seconds]
brakmic has quit [Remote host closed the connection]
brakmic has joined #zig
brakmic has quit [Remote host closed the connection]
brakmic has joined #zig
brakmic_ has joined #zig
brakmic_ has quit [Client Quit]
brakmic has quit [Ping timeout: 245 seconds]
brakmic has joined #zig
SimonNa has joined #zig
brakmic_ has joined #zig
brakmic has quit [Ping timeout: 245 seconds]
kristate has joined #zig
marmotini_ has quit [Ping timeout: 250 seconds]
jjido has joined #zig
Barabas has joined #zig
<Barabas> Hello, I have an import like this: const hf = @import("../algorithms/hash_functions.zig"); but zig complains with: error: import of file outside package path: '../algorithms/hash_functions.zig'
<Barabas> It used to work in the past, how do I import the other package?
schme245 has joined #zig
DutchGh0st has joined #zig
<DutchGh0st> what do you think of an ArrayVec? https://github.com/DutchGhost/ArrayVec/blob/master/src/main.zig
<DutchGh0st> sure, there is std.ArrayList, but that uses heap allocs, this uses an array
<Barabas> You can easily change the allocator, right?
<DutchGh0st> yes you can
schme245 has quit [Ping timeout: 250 seconds]
<Barabas> What
<DutchGh0st> change the allocator
<Barabas> What's the difference between push and push_unchecked? push also assumes no error occurs, right?
<Barabas> (Sorry accidently pressed enter while typing before ^^)
<DutchGh0st> the difference is that push calls try_push, which uses push_unchecked
<DutchGh0st> actually I could remove the assert in push_unchecked, yeah
<DutchGh0st> not sure if there is a debug that only gets compiled in the final result if you build a debug build
<DutchGh0st> it'd be nice to have like a `this_assertion_gets_only_compiled_in_debug_builds_assert(true)`, with a shorter name ofc :D
<Barabas> That might be what debug does, I'm not sure.
<DutchGh0st> Im planning on also include reference Iterators, and by value Iterators, and to try and have *everything* work at comptime
marmotini_ has joined #zig
<Barabas> Can you by chance help me with my problem?
<Barabas> I have an import like this: const hf = @import("../algorithms/hash_functions.zig"); but zig complains with: error: import of file outside package path: '../algorithms/hash_functions.zig'
<DutchGh0st> what does your file structure look like?
<DutchGh0st> what if you copy over the hash_functions.zig into /src ?
<Barabas> and the failing import is in containers/hash_map.zig
<DutchGh0st> mhhh
<DutchGh0st> cant see the isssue this quickly...looked at how std does it, they `const std = @import("../std.zig");` from zig/std/hash/crc.zig
<DutchGh0st> maybe there is something wrong with the paths?
<DutchGh0st> but I got to go, I'll be back in a couple hours, and read back the chat :)
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
ofelas has joined #zig
<Barabas> Thanks for taking a look!
marmotini_ has quit [Ping timeout: 244 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
brakmic has joined #zig
brakmic_ has quit [Ping timeout: 244 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
* mikdusan Barabas: —main-pkg-path ../
<mikdusan> this — zig test containers/hash_map.zig --main-pkg-path ..
<mikdusan> or — zig test containers/hash_map.zig --main-pkg-path .
Zaab1t has quit [Quit: bye bye friends]
<Barabas> Thanks that worked.
<andrewrk> hmm that namespacing thing did have the unfortunate side effect of making unit tests slightly more cumbersome didn't it?
Zaab1t has joined #zig
marmotini_ has joined #zig
darithorn has joined #zig
jjido has joined #zig
Zaab1t has quit [Quit: bye bye friends]
<mikdusan> andrewrk: git dynamically determines workspace root by searching up-tree from pwd. wonder if zig might consider similar - unless —main-pkg-path is specified, search up-tree for a package marker
<andrewrk> mikdusan, that's a good idea to keep in mind, especially considering the zig package manager is likely to have a declarative text file at package root dir\
marmotini_ has quit [Ping timeout: 268 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mgxm has quit [Ping timeout: 264 seconds]
mgxm has joined #zig
jjido has joined #zig
jjido has quit [Client Quit]
brakmic has quit [Remote host closed the connection]
marmotini_ has joined #zig
jjido has joined #zig
brakmic has joined #zig
jjido has quit [Client Quit]
jjido has joined #zig
jjido has quit [Client Quit]
vegecode has joined #zig
DutchGh0st has joined #zig
<vegecode> Hello. Can anyone tell me how to do the equivalent of the c command line -DSOME_DEFINE using the zig build system? I need a compile time const to make a const value be different depending on which MCU is being targeted.
<andrewrk> vegecode, is this for a @cImport?
<vegecode> No I'm tryin to port the Tivaware C library to zig for the TI Tiva series microcontrollers. I want my repo to be a one stop build and debug for those guys.
<DutchGh0st> arrays can only be indexed trough usizes, right?>
schme245 has joined #zig
<vegecode> andrewrk, For example, i want pub const my_define = 10; when TM4C123 is true, but pub const my_define = 11; otherwise. I see this done using @import("builtin") to distinguish operating systems, but can we add our own definitions to built-in to be referenced during compilation?
marmotini_ has quit [Ping timeout: 245 seconds]
jjido has joined #zig
<vegecode> andrewrk, Another use case, the critical one for me, is to include a different device specific header file depending on a flag passed in the build.
marmotini_ has joined #zig
<andrewrk> vegecode, ah ok I understand the use case. there is some very basic functionality for this, but it's planned to be improved. let me find you an example
jjido has quit [Client Quit]
<andrewrk> for the second use case, have a look at https://ziglang.org/documentation/master/#Import-from-C-Header-File
<andrewrk> @cImport takes an expression, which can be a block, and you can put any comptime logic in there
<vegecode> I don't want to import from a C header file. Translating the headers to zig with a sed script was the plan. Then I wanted to do the "usingnamespace ..." trick.
<vegecode> I tried translate-c but the header is filled with this: "#define REG_A (*((volatile *uint32_t)0x12345678))" and they don't translate well.
<kristate> vegecode: are you referring to build.zig ?
<andrewrk> vegecode, it's not well tested but maybe can be a solution for now
<kristate> andrewrk: does addBuildOption also get passed-through to zig cc ?
<kristate> or would that require an extra addCSourceFile("foo.c", [][]const u8{});
<andrewrk> no it writes a .zig file to disk and then maps it in with --pkg-begin/--pkg-end
<vegecode> andrewrk, That is exactly what I was looking for, thanks.
<vegecode> kristate, I am referring to build.zig. I'm not using any C files at all.
<vegecode> Trying not to anyways
<vegecode> I looked in that repo, I just didn't recognize it when I saw it. Thanks.
<andrewrk> vegecode, apologies if it breaks, it's not currently covered by tests
<andrewrk> but this use case is important, support will only improve in the future
<vegecode> Since I'm here, I had another question that I was unable to figure out myself, maybe an issue is needed.
<vegecode> Apparently llvm (or at least clang), can take a command line argument -mfpu=fpv4-sp-d16 or whatever the fpu model is and also -mfloat-abi=hard
<vegecode> and generate code that uses the fpu on a cortex m4 (and other mcus)
Ichorio_ has joined #zig
<vegecode> Looking at the clang soure code, I'm not experienced with C++ at all, I couldn't trace the command line option down to where llvm actually gets it.
<kristate> try -mllvm
<vegecode> I don't mind adding the functionality to Zig if required. -mllvm didn't do anything
<DutchGh0st> uh
<DutchGh0st> I dont get why my code doesn't compile
<andrewrk> vegecode, what is your target?
<andrewrk> specifically what are you passing for the ABI of the target?
<DutchGh0st> fn next(this: *@This()) ?*const T { <--- complains that I pass 0 args when I call it like `iter.next().?`
Ichorio has quit [Ping timeout: 245 seconds]
<vegecode> andrewrk, My example is in the link. I've tried armv7em-freestanding-eabi, armv7em-freestanding-eabihf
<vegecode> I've tried -mllvm-mfloat-abi=hard -mllvm-mfpu=fpv4-sp-d16
<vegecode> All different combos
<kristate> -mllvm requires a space
<andrewrk> vegecode, can you open an issue for this? even if you get it working with -mllvm, that's always a sort of last ditch effort workaround
<vegecode> kristate, Invalid argument: -mfpu=fpv4-sp-d16
<vegecode> That is what godbolt gives me when I put a space between them
<vegecode> I figured since it didn't complain without a space that must be the correct way
<andrewrk> DutchGh0st, did you know you can give a block to comptime? comptime { ... }
<DutchGh0st> oops
<DutchGh0st> :D
<vegecode> I will open an issue when my kids go back to bed. Naptime is over...
<DutchGh0st> but it still doesn't compile haha, it complains that the next() method on the struct returned from iter() needs 1 argument
<vegecode> Also, just throwing this out there, more calling conventions are needed for embedded. Clang can do IRQ, FIQ interrupt calling conventions on arm.
<DutchGh0st> but dont I give it one argument trough the dot notation?
<vegecode> I'll just have to do nakedcc with manual prologue and epilogue asm blocks
<vegecode> Thanks again for being so helpful
vegecode has quit [Quit: Page closed]
<emekankurumeh[m]> would we make calling conventions keywords or go the rust route of having them as strings?
<kristate> vegecode: try dropping the second m from -mfloat
<andrewrk> emekankurumeh[m], https://github.com/ziglang/zig/issues/661
<andrewrk> DutchGh0st, I'm looking at your code, just a moment
<DutchGh0st> thanks :), np
<kristate> vegecode: hopefully you check the logs -- it looks like godbolt escapes/removes -mllvm from comp options
<kristate> so adding -mllvm -float-abi=hard becomes -float-abi=hard
<DutchGh0st> is there a way to have multiple variables with the same name in the same scope? this is usefull when you you have function signatures like `fn ...(self: *Self) ...`, when you have nested functions where the outer function returns a struct
<andrewrk> DutchGh0st, nope, it's not possible, so you'll have to come up with different names
<DutchGh0st> ah, thats why I used `this` within the iter struct
<DutchGh0st> ohhh wait
<DutchGh0st> stop searching andrewrk
<DutchGh0st> I never initted the struct \o/
<andrewrk> DutchGh0st, that's fine, I got distracted with this anyway: https://github.com/ziglang/zig/commit/918dbd4551f6c737d1c4b7416ef40b59c902eac8
<DutchGh0st> hehe
<schme245> Zig shower thought of the day: it seems to me that `var` and `const` are overloaded, since they are used to signify both "this variable will (not) be reassigned" and "this memory will (not) be modified"
<schme245> has this been discussed before, and is anything under consideration for separating these two concepts? (different keywords perhaps?)
<andrewrk> schme245, I think `let` is still on the table
<andrewrk> it's a tiny problem that `var` is easier to type than `const`
<schme245> so `let` would replace `const`, but the semantics would otherwise be the same?
<schme245> or something more Rust-ish (`let mut` and all that jazz)?
<DutchGh0st> what about `var` and `var mut` ?
<andrewrk> DutchGh0st, your `iter` variable is a `type`. so `iter.next()` is actually just a namespace lookup, calling a static function with no args
<andrewrk> schme245, yes that's what I was suggesting just now. `let mut` would reverse the "default" of memory const-ness which I'm not sure is a good idea for zig
<DutchGh0st> error: cannot store runtime value in compile time variable: const end = @intToPtr(*const T, @ptrToInt(start) + self.len());
<schme245> an example: in `var array = ArrayList(u8).init(allocator); try array.append(1);`, it would be nice to be able to say "`array` will always refer to the same array (so `array = ...` would be a compile error), but the memory might still be modifed (so you can append stuff)
<schme245> right now that's not possible to express, right?
jjido has joined #zig
<andrewrk> you could express it like this: `var array_memory = ArrayList(u8).init(allocator); const array = &array_memory; try array.append(1);`
<schme245> ooh, I kinda like that!
<DutchGh0st> is @ptrToInt comptime only?
jjido has quit [Client Quit]
<schme245> no
<DutchGh0st> huh
<andrewrk> DutchGh0st, I think it's a smell that all your tests are in comptime blocks
<andrewrk> why wouldn't they work at runtime?
<DutchGh0st> oh they would
<DutchGh0st> but I want everything to work at both comp and runtime
<andrewrk> ah. I usually in this case put the test in a function and then: doTheTest(); comptime doTheTest();
<DutchGh0st> still unable to evaluate const expression...
<DutchGh0st> oh, right, instead of `type` the return type of iter() becomes `build_iter(*const T)`
<DutchGh0st> *then* it works
jjido has joined #zig
schme245 has quit [Remote host closed the connection]
marmotini_ has quit [Ping timeout: 245 seconds]
<DutchGh0st> what is *the* way to increment a pointer?
<andrewrk> first, try to use a slice or array rather than a pointer
<andrewrk> and increment the index
<andrewrk> otherwise, you'll need an unknown length pointer, and you can use += 1
<DutchGh0st> well Im trying to implement iterating using just 2 ptr's, a start and end
<DutchGh0st> but it seems to go wrong somewhere, and I dont know where
<DutchGh0st> http://prntscr.com/mw0ter <-- the VALUE should be 1, then 2, 3, 4
<andrewrk> mikdusan, here's part 1 of the summary of caching issue: https://github.com/ziglang/zig/issues/2044
<DutchGh0st> and Im just incrementing the pointer with `ptr = @intToPtr(TYPE, @ptrToInt(ptr) + 1)`
Barabas has quit [Ping timeout: 256 seconds]
brakmic has quit [Ping timeout: 244 seconds]
brakmic_ has joined #zig
<andrewrk> @intToPtr / @ptrToInt is a huge code smell if you're not doing something directly with hardware
<andrewrk> almost certainly incorrect if you're making a generic data structure
<DutchGh0st> why, a pointer is just an address, which is just a number
<DutchGh0st> and looking at my screenshot, the pointers indeed all go up by 1 with respect to the previous
<andrewrk> the compiler loses some type information when you do that. for example the alignment and the const-ness
<andrewrk> why don't you just make your ptr be a [*] instead of * and then you can do + 1
<andrewrk> or use @ptrCast
<DutchGh0st> oh wait, I bet what it is
<DutchGh0st> haha
<DutchGh0st> its adding one to the pointer
<DutchGh0st> not sizeOf(T)
<DutchGh0st> duh
brakmic_ has quit [Remote host closed the connection]
brakmic has joined #zig
schme245 has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
brakmic has quit [Remote host closed the connection]
brakmic has joined #zig
kristate has quit [Remote host closed the connection]
DutchGh0st has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
<andrewrk> mikdusan, part 2: https://github.com/ziglang/zig/issues/2045
jevinski_ has joined #zig
jevinskie has quit [Ping timeout: 250 seconds]
mikdusan has quit [Ping timeout: 268 seconds]
darithorn has quit [Remote host closed the connection]
mikdusan has joined #zig
kristate has joined #zig
wilsonk has quit [Read error: No route to host]
brakmic has quit []
jjido has joined #zig
Amsel has joined #zig
<mikdusan> andrewrk: #2045; am I correct to assume (1) mtime timewarps is not something you care about supporting except maybe a “timewarp detected” warning message. ie we assume that mtime may have low precision but it can be relied on to increase and never go backwards
<Amsel> What is the rationale behind "error: expected type 'u3', found 'u32'" for "u5(0x01) << s;" ? If s would be u3 I could still shift 7 positions?
<mikdusan> and (2) the main issue with 1.0 second granularity is the race that exists for { edit-source, save, build } within the 1-second time frame and ends up in a “nothing to do” situation if the main check is: do_nothing when “!(src.mtime > obj.mtime)”
shawn_ has joined #zig
darithorn has joined #zig
Ichorio_ has quit [Ping timeout: 246 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jevinski_ has quit [Ping timeout: 250 seconds]
schme245 has quit [Remote host closed the connection]
darithorn has quit [Remote host closed the connection]
wilsonk has joined #zig
Amsel has quit [Quit: Page closed]