Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

F.3 Platform Surface

With no C capability imports, the C backend implements only the core intrinsics. It does not provide:

  • Linux __syscall0__ through __syscall6__
  • browser/DOM/canvas intrinsics
  • backend-provided builtin constants such as SYS_WRITE or STDOUT

Use importable C capability modules for common hosted C APIs:

import p"../third_party/c/stdlib.udewy"

let main = ():>int => {
    let buf:int = calloc(4 8)
    return buf =? 0
}

The checked-in C capability modules live under udewy/third_party/c/. The C backend recognizes imports of these ordinary udewy source modules and maps them to its private capability names:

  • hosted.udewy: marks that the program targets ordinary hosted C
  • stdio.udewy: imports hosted.udewy, declares minimal stdio externs, and lets the C backend include <stdio.h>
  • stdlib.udewy: imports hosted.udewy, declares minimal stdlib externs, and lets the C backend include <stdlib.h>
  • math.udewy: imports hosted.udewy, lets the C backend include <math.h>, and links the host math library

This keeps the portability boundary explicit in source. Importing no C capability modules leaves the program in the minimal/freestanding-oriented profile.