Include of a platform-specific system header

ID

c.portability.restrict_system_includes

Severity

low

Remediation Complexity

medium

Remediation Risk

medium

Remediation Effort

medium

Resource

Portability

Language

C / C++

Description

This includes a platform-specific system header, which ties the code to a single operating system and hurts portability. Guard the include behind a platform macro (e.g. #ifdef _WIN32) and provide a portable abstraction, or replace it with a cross-platform alternative.

Rationale

This includes a platform-specific system header, which ties the code to a single operating system and hurts portability. Guard the include behind a platform macro (e.g. #ifdef _WIN32) and provide a portable abstraction, or replace it with a cross-platform alternative.

The following code illustrates the pattern detected by this rule:

// FLAGGED: Include of a platform-specific system header
#include <unistd.h>

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved