REW

What Language Is Zephyr RTOS?

Published Aug 29, 2025 5 min read
On this page

Zephyr RTOS is primarily written in C, with robust support for applications written in C++ and an active, community-driven effort for Rust support. The choice of C for the core kernel and APIs is foundational to its role as a real-time operating system (RTOS) for resource-constrained devices, while its support for other languages expands its usability and addresses modern software development needs.

The dominant role of C

The C programming language is the heart of the Zephyr RTOS, a design choice made for several critical reasons inherent to embedded systems development:

  • Low-level access and control: C provides direct access to hardware, a necessity for writing drivers, configuring memory, and managing peripherals, tasks that are fundamental to an RTOS. This low-level control allows developers to optimize for performance and memory usage, both of which are paramount in resource-constrained environments like IoT devices.
  • Performance and footprint: As a compiled language, C produces highly efficient machine code with minimal overhead. The lack of a large, mandatory runtime or garbage collector results in a small memory footprint, which is crucial for microcontrollers with limited RAM and flash memory.
  • Portability: The C standard, particularly modern versions like C11, is well-defined and widely supported across different architectures. This makes it possible to port Zephyr to a vast array of platforms, including ARM, RISC-V, and x86, with a high degree of code reuse.
  • Legacy and developer community: C is the lingua franca of embedded systems. Decades of development in this field have produced a massive ecosystem of existing C code, libraries, and experienced developers. Building Zephyr on C ensures a large pool of available talent and easy integration with existing codebases.
  • API implementation: All Zephyr APIs are implemented in C, making it the native and most direct way to interact with the kernel and system services.

Expanding horizons with C++

While C forms the core, Zephyr offers strong support for application development in C++, enabling developers to leverage the benefits of object-oriented programming (OOP). This support is particularly valuable for building complex applications on top of the Zephyr kernel, as it allows for better code organization, reusability, and maintainability.

Key aspects of Zephyr's C++ support include:

  • Build system integration: The Zephyr build system, based on CMake, can automatically detect C++ source files (e.g., .cpp, .cxx) and use a C++ compiler to build them.
  • Standard library options: Zephyr does not ship with its own C++ standard library implementation but allows linking against a toolchain's library. For instance, with the Zephyr SDK, developers can use the GNU C++ Library (libstdc++), which provides a rich set of features, including the Standard Template Library (STL).
  • Subset of features: To maintain its embedded focus, Zephyr supports a subset of C++ features. Some higher-level, OS-dependent features like std::thread are generally unsupported or have minimal implementations, as the Zephyr kernel provides its own threading and synchronization APIs.
  • Memory management: A minimal C++ library provides the essential operators (new, delete) and global constructors needed for basic C++ functionality.

Community-driven Rust support

Rust, a modern systems programming language, is gaining significant traction in the embedded world due to its emphasis on memory safety, security, and robustness. Zephyr includes experimental, community-driven support for applications written in Rust, allowing developers to benefit from its advanced features.

Developing Rust applications for Zephyr involves:

  • Cargo integration: Rust projects use Cargo for package management, which is integrated with Zephyr's build system. This allows for seamless handling of dependencies from crates.io, provided they support no-std development.
  • Memory safety: Rust's ownership and borrowing system prevents common C/C++ programming errors, such as null pointer dereferences and data races, without relying on a garbage collector. This makes it an ideal language for developing safe and secure firmware.
  • Module-based integration: Rust support is handled as an optional module within the Zephyr workspace, which can be enabled using the west tool.
  • Growing ecosystem: The Rust community is actively developing crates (packages) specifically for embedded use cases, and many are compatible with the Zephyr ecosystem.

Specialized languages and build system

Beyond the core application languages, Zephyr's ecosystem incorporates other languages for its build and configuration infrastructure:

  • Python: Crucial for Zephyr's build and configuration systems, which are borrowed from the Linux kernel. Python is used to implement tools like Kconfig and the DeviceTree utilities, allowing for system configuration in a portable manner across different operating systems.
  • CMake: The build system is powered by CMake, which provides a cross-platform framework for building applications on Linux, macOS, and Windows.
  • Kconfig language: A specialized language used to describe and manage the thousands of configuration options available in Zephyr.

The complete picture: A polyglot embedded ecosystem

In summary, Zephyr's language support is best described as a multi-layered ecosystem:

  • The Kernel: The core of Zephyr, including the kernel, device drivers, and system APIs, is built with C for maximum efficiency, control, and portability.
  • Applications: Developers can write their applications in C for full access to all features or in C++ to take advantage of object-oriented design patterns.
  • Emerging options: Rust is available for developers seeking enhanced memory safety and modern language features, particularly for security-critical applications.
  • Infrastructure: The build and configuration systems rely on Python and CMake, allowing for a robust and configurable development environment.

This layered approach makes Zephyr highly adaptable, providing a stable, high-performance C core while remaining open to modern development practices and alternative languages.

Enjoyed this article? Share it with a friend.