summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-25 14:38:28 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-25 14:38:28 +0000
commit8b720543f538862796fec0ff6b7ea12cb140bf0f (patch)
tree0f4a20d305842ffed01cdd9536fd937d82cd76d4 /README.md
parent0bd7b99fbf813415b9a0217eaa2a4e8f6f74e1ea (diff)
Fix for #90
Diffstat (limited to 'README.md')
-rw-r--r--README.md19
1 files changed, 19 insertions, 0 deletions
diff --git a/README.md b/README.md
index 9159ea2..e87b8ea 100644
--- a/README.md
+++ b/README.md
@@ -51,6 +51,7 @@ Join the discussion, share demos, ask questions, or report bugs in the official
- [Const Arguments](#const-arguments)
- [Default Arguments](#default-arguments)
- [Lambdas (Closures)](#lambdas-closures)
+ - [Raw Function Pointers](#raw-function-pointers)
- [Variadic Functions](#variadic-functions)
- [5. Control Flow](#5-control-flow)
- [Conditionals](#conditionals)
@@ -319,6 +320,24 @@ var double = x -> x * factor; // Arrow syntax
var full = fn(x: int) -> int { return x * factor; }; // Block syntax
```
+#### Raw Function Pointers
+Zen C supports raw C function pointers using the `fn*` syntax. This allows seamless interop with C libraries that expect function pointers without closure overhead.
+
+```zc
+// Function taking a raw function pointer
+fn set_callback(cb: fn*(int)) {
+ cb(42);
+}
+
+// Function returning a raw function pointer
+fn get_callback() -> fn*(int) {
+ return my_handler;
+}
+
+// Pointers to function pointers are supported (fn**)
+var pptr: fn**(int) = &ptr;
+```
+
#### Variadic Functions
Functions can accept a variable number of arguments using `...` and the `va_list` type.
```zc