Skip to content

Document C shims in the C-FFI tutorial#586

Open
SeanTAllen wants to merge 1 commit into
mainfrom
tutorial-c-shims
Open

Document C shims in the C-FFI tutorial#586
SeanTAllen wants to merge 1 commit into
mainfrom
tutorial-c-shims

Conversation

@SeanTAllen

@SeanTAllen SeanTAllen commented Jun 14, 2026

Copy link
Copy Markdown
Member

Documents the C shims feature from ponylang/ponyc#5469: a .c file placed next to a package's .pony files is compiled by ponyc with an embedded clang and linked directly, with cdefine:/cincludedir: use schemes to configure the compile.

The change adds a C Shims page and reframes the C-FFI section around two paths: link a library, or write a shim for glue that bridges Pony to C. It retires the old C ABI page (almost entirely a hand-compile-a-library walkthrough), redirects its URL to C Shims, and moves the extern "C" name-mangling note to the linking page. Shims are framed as helper/bridge code, not a way to write C libraries; for a library's worth of C, the guidance is to build it as a library and link it.

Draft / do not merge: the feature isn't in a ponyc release yet. Before un-holding, re-verify against the shipping release:

  • the verbatim Compiling C shims build-step label and the exact Windows error string the page quotes
  • that --safe gates shim compilation, and that a cdefine:/cincludedir: in a package with no .c is an error (both are implemented in #5469 but listed as parked items in that PR, so they could still change)

@netlify

netlify Bot commented Jun 14, 2026

Copy link
Copy Markdown

Deploy Preview for pony-tutorial ready!

Name Link
🔨 Latest commit 805934d
🔍 Latest deploy log https://app.netlify.com/projects/pony-tutorial/deploys/6a3304914cea050008b7848e
😎 Deploy Preview https://deploy-preview-586--pony-tutorial.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Jun 14, 2026
Comment thread docs/c-ffi/c-shims.md Outdated

`cdefine:` is unrelated to ponyc's own `--define`/`-D` flag, which drives Pony's `ifdef`. One sets a C preprocessor macro for your shims; the other selects Pony build flags.

`use "cinclude:PATH"` adds an include search directory (clang's `-I`). A relative path is resolved against the package's directory.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These will need to be updated to match the name change discussed today (cincludedir)

@jemc jemc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved conditional on the name change mentioned

ponylang/ponyc#5469 lets ponyc compile a .c placed next to your .pony
files and link it directly, with no separate build system. The tutorial
needs to cover it, so this adds a C Shims page.

This also reframes the section. We no longer teach how to hand-compile C
into a library; the choice is now "link a library or write a shim," with
shims framed as glue that bridges Pony to C rather than a way to author C
libraries. That retires the old C ABI page, which was mostly a
compile-it-yourself walkthrough. A redirect points the old URL at C
Shims, and the one piece worth keeping from it, the extern "C"
name-mangling note, moves to the linking page.

The feature is not in a release yet, so this is a draft: hold the merge
until ponyc ships it.
@SeanTAllen SeanTAllen marked this pull request as ready for review June 18, 2026 13:52
@SeanTAllen SeanTAllen mentioned this pull request Jun 18, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discuss during sync Should be discussed during an upcoming sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants