# Which Platform Dependencies Does MulleObjC Aim to Avoid?

> MulleObjC avoids platform dependencies like unistd.h and POSIX interfaces. Discover how it achieves maximum portability with the standard C library for C11 platforms.

- Repository: [mulle-objc/mulleobjc](https://github.com/mulle-objc/mulleobjc)
- Tags: deep-dive
- Published: 2026-03-07

---

**MulleObjC deliberately avoids platform-specific headers such as `<unistd.h>` and POSIX-only interfaces, depending exclusively on the standard C library for maximum portability across C11-conforming platforms.**

The [mulle-objc/mulleobjc](https://github.com/mulle-objc/mulleobjc) repository implements a strict portability policy designed to make the Objective-C runtime compile anywhere standard C is available. According to the project source code, the library explicitly excludes operating system-specific headers like `<unistd.h>`, `<sys/...>` headers, and other POSIX dependencies that would limit deployment to Unix-like systems.

## The Standard C Library Design Philosophy

MulleObjC is architected to depend **only on the standard C library**. This design choice is stated explicitly in the project’s [`README.md`](https://github.com/mulle-objc/mulleobjc/blob/main/README.md) at lines 6-7:

> “MulleObjC supplies the most basic runtime components … **depends on standard C libraries only and for instance not on `<unistd.h>`**.”

Consequently, the library targets **C11-conforming environments** without requiring underlying OS-specific system calls or data structures. This approach ensures the runtime can be compiled and executed on embedded systems, bare-metal environments, and non-POSIX operating systems that provide only a basic C standard library implementation.

## Specific Platform Headers Excluded

The codebase deliberately omits several categories of platform-specific dependencies:

- **`<unistd.h>`** – The Unix standard header providing access to system calls like `read()`, `write()`, and `fork()`
- **`<sys/...>` headers** – System-specific headers for sockets, process control, and kernel interfaces
- **POSIX-only interfaces** – Functions and types not defined in ISO C standards

According to the source analysis, any inclusion of `<unistd.h>` appears **only in test sources**, never in the library’s public API or implementation files.

## Code Structure: Library vs. Test Files

### Production Code

Typical usage includes only standard headers (e.g., `<stddef.h>`, `<stdio.h>`, `<stdint.h>`) and Mulle-specific umbrella headers. The public umbrella header [`src/mulle-objc.h`](https://github.com/mulle-objc/mulleobjc/blob/main/src/mulle-objc.h) includes only Mulle-ObjC runtime headers without pulling in platform-specific dependencies.

```c
/* Minimal MulleObjC source file – no platform headers required */
#include <stddef.h>                     // Standard C header
#include <stdio.h>                      // Standard C header
#include <mulle-objc/MulleObjC.h>      // MulleObjC's public API

int main(void)
{
    printf("MulleObjC runs on pure C11 environments!\n");
    return 0;
}

```

### Test Code Exceptions

The test file `test/NSThread/thread-usermap.m` includes `<unistd.h>`, but this is **solely for test purposes** and not part of the library’s distributed code:

```objc
/* Test source – platform specific, not part of the library */
#include <unistd.h>   // Used only in test harness

```

This separation ensures that while the test suite may utilize platform-specific features to validate functionality, the runtime itself remains portable.

## Key Implementation Files

Several source files demonstrate this header policy in practice:

**[`src/mulle-objc.h`](https://github.com/mulle-objc/mulleobjc/blob/main/src/mulle-objc.h)** – The public umbrella header includes only Mulle-ObjC runtime headers, deliberately avoiding any platform-specific includes.

**[`src/generic/include.h`](https://github.com/mulle-objc/mulleobjc/blob/main/src/generic/include.h)** – Shows inclusion of only standard C headers (`<assert.h>`, `<stdio.h>`, `<stdlib.h>`, …), establishing the dependency baseline for the entire project.

**[`src/struct/NSRange.h`](https://github.com/mulle-objc/mulleobjc/blob/main/src/struct/NSRange.h)** – Demonstrates use of standard `<assert.h>` only, without requiring platform-specific dependencies.

**`test/NSThread/thread-usermap.m`** – Example of a test that *does* include `<unistd.h>`, illustrating that such dependencies are confined to the test suite rather than the library implementation.

## Summary

- MulleObjC depends **only on standard C libraries**, explicitly avoiding `<unistd.h>` and POSIX headers
- The library compiles on any **C11-conforming platform** without OS-specific dependencies
- Platform-specific headers like `<unistd.h>` appear **only in test files**, not in production code
- Key files like [`src/mulle-objc.h`](https://github.com/mulle-objc/mulleobjc/blob/main/src/mulle-objc.h) and [`src/generic/include.h`](https://github.com/mulle-objc/mulleobjc/blob/main/src/generic/include.h) enforce this portability policy

## Frequently Asked Questions

### Why does MulleObjC avoid unistd.h?

MulleObjC avoids `<unistd.h>` because it is a POSIX-specific header that would limit portability to Unix-like systems. By excluding it, the runtime remains compatible with embedded systems, Windows, and other non-POSIX environments that provide only standard C library support.

### Can MulleObjC run on non-POSIX systems?

Yes. Because MulleObjC depends solely on standard C libraries and C11 conformance, it can compile and run on any platform providing a standard C implementation. This works regardless of whether the underlying system supports POSIX standards.

### What standard headers does MulleObjC use instead?

According to [`src/generic/include.h`](https://github.com/mulle-objc/mulleobjc/blob/main/src/generic/include.h) and related files, MulleObjC uses standard headers such as `<stddef.h>`, `<stdio.h>`, `<stdint.h>`, `<assert.h>`, and `<stdlib.h>`. These are all defined by the C standard rather than platform-specific extensions, ensuring broad compatibility.

### Are there any exceptions to this rule?

The only exceptions occur in the **test suite**, where files like `test/NSThread/thread-usermap.m` include `<unistd.h>` for testing specific functionality. The production library code in `src/` maintains strict adherence to standard C library dependencies only.