Finch/tests/new/c_unions_macros.fch
Nexoniarz ff72f68804 static inline C functions (mingw's printf and time), macOS libraries that call their host, lld's missing-library message
- a static inline function in a header is called through a pointer a small C file keeps
  (void *finch_inl_f = &f), built with the program's include folders and cached
- --shared on macOS links with -undefined dynamic_lookup, as a .so does on Linux
- "unable to find library -lx" (lld, MinGW) gives the library-not-found advice
- the language server test shows the index records when alias completion fails

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GzNP6r8dg6WDxUVZy8wjL
2026-10-29 11:53:24 +01:00

30 lines
994 B
Text

// C unions (SDL_Event-style) and #defines that are expressions, strings or casts
import "cunion.h"
import "stdlib.h"
link "cunion.c"
fn main() {
print(EV_MOTION, EV_KEY, FLAG_BIG, FLAGS_BOTH, HALF, GREETING, LONG_NAME)
u64 flags = FLAG_BIG | FLAG_GL
u32 small = EV_KEY
print(flags, small)
Event e
if poll_event(addr(e)) != 0 && e.type == EV_MOTION {
print("motion", e.motion.x, e.motion.y)
}
k := Event(key: Key(type: EV_KEY, key: 32))
print(k.type == EV_KEY, k.key.key)
[]Event queue
queue.push(e)
queue.push(k)
print(queue[1].key.key, queue.len)
Tagged t
t.as.f = 0.5
print(t.as.f)
print(abs(-2.5), abs(-3), min(EV_KEY, 7)) // Finch's abs, not C's int-only one
bg := RAYWHITE // #define RAYWHITE (Color){ 245, 245, 245, 255 }
print(bg.r, bg.a, DARK.g, DARK.a, HALF_UP.x, HALF_UP.y)
print(twice(21)) // static inline in the header
}