Files
sx/examples/1223-ffi-extern-fn.sx
agra 811a280517 refactor(ffi-linkage): Phase 9.3 — purge 'foreign' from comments (src caps + examples + docs)
src/: ~21 capital-Foreign comments the case-sensitive verify grep missed
(Foreign-class→Runtime-class, Foreign path→Runtime path, Foreign decls→Extern decls,
FOREIGN function→extern function) across calls/inst/ffi_objc/jni_descriptor/emit_llvm/
c_import/lower.*/ops. src 'foreign' now = ONLY the hash_foreign token + 4 rejection
messages (9.0-delete targets). examples/*.sx comments → extern/runtime-class (1219
stdout regen; KEPT 1176). docs/inline-asm-design + debugger purged. Comments only —
no build impact. 9.0 ratified: DELETE hash_foreign token next.
2026-06-15 10:52:56 +03:00

15 lines
547 B
Plaintext

// extern function binding (FFI-linkage stream, Phase 1): bind libc's `abs`
// directly via the bare `extern` linkage modifier — no `extern`, no
// `#library`. `extern` ⇒ external linkage + C ABI + no sx ctx; the symbol
// resolves against the default-linked libc at link time. The sx name `abs`
// IS the C symbol (no rename — the `extern LIB "csym"` forms land in 1.2).
#import "modules/std.sx";
abs :: (n: i32) -> i32 extern;
main :: () -> i32 {
print("abs(-7) = {}\n", abs(xx -7));
print("abs(42) = {}\n", abs(xx 42));
0
}