> mkdir c:\llvm20
> cd c:\llvm20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <cstdint> | |
#include <optional> | |
enum class ReleaseMouseButtons { No, Yes }; | |
struct SendMousePos { int32_t x; int32_t y; }; | |
void send_mouse_move(std::optional<SendMousePos> pos, ReleaseMouseButtons); | |
void send_mouse_button(uint32_t button_flags); | |
void send_mouse_scrolls(bool precise, float delta_x, float delta_y); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import datetime | |
import hashlib | |
import filecmp | |
import glob | |
import json | |
import os | |
import pathlib | |
import re | |
import shutil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static LRESULT CALLBACK LoggingWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) | |
{ | |
MsgNode msg_node; | |
WndProcEnter(&msg_node, hwnd, msg, wparam, lparam); | |
if (false) { | |
char buf[1000]; | |
FormatMessages(buf, 0, sizeof(buf), &msg_node); | |
TRACELOG(LOG_INFO, "WndProc: %s", buf); | |
} | |
LRESULT result = ActualWndProc(hwnd, msg, wparam, lparam); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
pub const Params = struct { | |
Return: type, | |
Args: type, | |
}; | |
pub fn with( | |
comptime T: type, | |
comptime params: Params, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// perftest.zig | |
// | |
// build with | zig build-exe -O ReleaseFast perftest.zig | |
// linux test | poop "./perftest std" "./perftest custom" | |
// | |
const std = @import("std"); | |
const tokens = @embedFile("tokens.zig"); | |
pub fn main() void { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const builtin = @import("builtin"); | |
pub fn build(b: *std.Build) void { | |
const target = b.standardTargetOptions(.{}); | |
const win32_dep = b.dependency("win32", .{}); | |
const win32_mod = win32_dep.module("zigwin32"); | |
const exe = b.addExecutable(.{ | |
.name = "example", | |
.root_source_file = b.path("example.zig"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn hns_from_filetime(filetime: win32.FILETIME) u64 { | |
return @as(u64, filetime.dwLowDateTime) | | |
(@as(u64, filetime.dwHighDateTime) << 32); | |
} | |
const TimeFmt = struct { | |
hns: u64, | |
pub fn format( | |
self: TimeFmt, | |
comptime fmt: []const u8, | |
options: std.fmt.FormatOptions, |
Some of my thoughts on using enums in place of bool
, adding a way to opt-in to an implicit conversion could have some benefits.
Zig enums provide a convenient way to represent dual-state values (booleans) with domain-specific names. An example of this is std.builtin.Signedness
:
const Signedness = enum { unsigned, signed };
- Configure build (build.zig's build fn is invoked)
- If
lazyDependency
is ever called during configuration, exit the build runner and resolve the missing dependencies and rebuild/rexecute
Example Usage:
const foo_enabled = b.option(bool, "foo", "Enable foo stuff") orelse false;
if (foo_enabled) {
if (b.lazyDependency("foo", .{})) |foo_dep| {
NewerOlder