We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1374dcb commit b226e57Copy full SHA for b226e57
hello-world.py
@@ -0,0 +1,15 @@
1
+from cffi import FFI
2
+
3
+cffi = FFI()
4
+cffi.cdef(
5
+ """
6
+ void print(char* x);
7
8
+)
9
10
+import os
11
12
+helloWorld = cffi.dlopen(os.path.abspath("hello-world.dll"))
13
14
+# pass in null-terminated array
15
+helloWorld.print(b"Hello world\x00")
hello-world.zig
@@ -0,0 +1,9 @@
+const std = @import("std");
+// messageZ must be null-terminated
+export fn print(messageZ: [*]u8) void {
+ // [*:0]u8 is not allowed by C ABI, cast to right type
+ const message = @ptrCast([*:0]u8, messageZ);
+ std.debug.print("{s}", .{message});
+}
0 commit comments