# Linux kernel module example in Zig

**URL:** <https://ziggit.dev/t/linux-kernel-module-example-in-zig/15923>\
**Category:** Showcase\
**Tags:** c, build-system, linux\
**Created:** [June 4, 2026, 10:04pm UTC](https://ziggit.dev/t/linux-kernel-module-example-in-zig/15923 "2026-06-04T22:04:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![usebeforefree](https://ziggit.dev/user_avatar/ziggit.dev/usebeforefree/32/6726_2.png) [@usebeforefree](https://ziggit.dev/u/usebeforefree)\
**Post date:** [June 4, 2026, 10:04pm UTC](https://ziggit.dev/t/linux-kernel-module-example-in-zig/15923/1 "2026-06-04T22:04:49Z")

</div>

# Zig kernel module:

[https://codeberg.org/usebeforefree/zig-kernel-module](https://codeberg.org/usebeforefree/zig-kernel-module)

* * *

Noticed nobody has shared an attempt at writing a kernel module with Zig recently. Found this [old one](https://github.com/Mic92/zig.ko), and took it as inspiration. I am open to hearing suggestions, as I am not at all an expert in kernel modules, and would like to learn more about this topic. I will probably use this template to actually try write something useful.

It currently uses `make` for calling `zig build`, which then omits an object, that’s then linked to `module.c`.

### Supported Zig versions

Made it work with `0.16.0`

---

<div class="post-metadata">

**Author:** ![WeeBull](https://ziggit.dev/user_avatar/ziggit.dev/weebull/32/6828_2.png) [@WeeBull](https://ziggit.dev/u/WeeBull)\
**Post date:** [June 5, 2026, 6:19pm UTC](https://ziggit.dev/t/linux-kernel-module-example-in-zig/15923/2 "2026-06-05T18:19:49Z")

</div>

Why does it need the `module.c`? Is it not possible to export the right interface directly from zig?

---

<div class="post-metadata">

**Author:** ![usebeforefree](https://ziggit.dev/user_avatar/ziggit.dev/usebeforefree/32/6726_2.png) [@usebeforefree](https://ziggit.dev/u/usebeforefree)\
**Post date:** [June 5, 2026, 6:33pm UTC](https://ziggit.dev/t/linux-kernel-module-example-in-zig/15923/3 "2026-06-05T18:33:57Z")

</div>

You need to include the module macros that are defined in `linux/module.h`. Which you can technically make a wrapper for, and use inside of Zig code.

I am looking into a better/more ergonomic way of doing this.
