Skip to main content

Module runtime

Module runtime 

Source
Expand description

The headers the compiler ships, and the directory they appear to live in.

Design: spec/04-driver-and-cli.md section 4.4.

A hosted C implementation is two halves. The library ships <stdio.h> and everything that declares a function you link against. The compiler ships the handful of headers whose contents are not the library’s to know: <stdarg.h> is the target’s calling convention, <limits.h> and <float.h> are the target’s types, and <stddef.h> is the ABI. No library can write those, which is why every compiler carries its own copies and why a compiler that carries none cannot preprocess a program as ordinary as SQLite.

They are in the binary rather than on disk. A compiler that has to find its own installation directory before it can preprocess a file is a compiler that stops working when it is copied somewhere else, and a single static binary that works from anywhere is worth more here than the ability to edit a header without rebuilding.

Since they are not on disk they need a name, because the search path is a list of directories and a diagnostic has to be able to say where a header came from. That name is DIR, and the angle brackets are the point: no directory a user can create is spelled that way, so nothing on the real file system can shadow these or be shadowed by them.

Constants§

DIR
The directory the shipped headers appear to be in.

Functions§

header
The text of one shipped header, by its name alone.
names
The names of the shipped headers, sorted.
read
Reads a path that an include search produced, when it names a shipped header.