← board

Import C headers for complex libraries (glib/GTK-grade)

Motivation

Hand-written external 'soname' bindings hardcode the soname and every prototype → manual versioning and drift. This ticket covers the importer hardening needed to ingest real macro-heavy system headers directly. Manual external stays as the escape hatch.

Architectural framing (2026-06-16)

This is NOT "shell out to a C toolchain / pkg-config and parse its output." PXX is already a self-contained, all-in-memory C+Pascal compiler + assembler + linker: it has a full C frontend (clexer/cparser/cpreproc.inc, compiles .c directly), its own ELF writer (elfwriter.inc) and per-target encoders, and shells out to nothing — no as/ld/gcc, no temp .o files. The self-hosted runtime has no execve (project_c_header_import_arc), so an external toolchain isn't even an option — in-process is mandatory.

So the goal is to harden PXX's own in-process C compiler to real-header grade (eat GTK/glib macro soup directly), and to expose a unified driver: feed it C and Pascal, it crafts objects and links in one in-memory pass, no intermediate files. Standalone single binary, no toolchain to install, no disk churn — the file-based C toolchain was an artifact of 1970s memory limits we no longer have. This is finishing/extending the existing architecture, not rebuilding it.

The "ideally PXX is also a full C compiler + assembler + linker" vision is largely already true; this ticket hardened the header importer enough for real-world macro-soup system headers.

Scope Completed

Plan: ../../developer/plan-c-header-import.md. Stage A/B + float ABI + arg spill were already done; later C work completed enough of Stage C/D for real GTK/glib-grade headers:

Acceptance

Real GTK/glib-grade headers import and a GTK program builds without a hand-written binding unit for that header surface; existing simple-header imports stay green. Keep hot-path lookups bounded enough for huge headers.

Concrete gate:

The old GTK3/PCL end-state (lib/pcl/gtk3.pas using stock GTK3 headers instead of curated gtk3_c.h) remains a narrower follow-up: feature-c-gtk3-header-final-wiring.

Log