#include or #import operand is not <filename> or "filename"

ID

objectivec.correctness.include_directive_malformed

Severity

low

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Preprocessor

Language

Objective-C

Description

Reports an #include or #import whose operand is neither a <filename> nor a "filename" header name - typically a macro that expands to one, a so-called computed include, or a directive left with no operand at all.

Rationale

The two bracketed forms are the only ones the C standard defines for a header name. Anything else is a computed include, whose operand is macro-expanded first and is then required to resolve to exactly one of those forms; how the resulting token sequence is turned back into a file name is implementation-defined, so the same source can pick a different header, or fail to compile at all, on another toolchain. It also defeats every tool that reads include graphs - dependency generation, header pruning, module maps - because the file being included is not visible in the text.

The following code illustrates the pattern detected by this rule:

// FLAGGED: #include or #import operand is not <filename> or "filename"
#include XY_PLATFORM_HEADER

Remediation

Write the header name literally, #import <XYCore/XYPlatform.h> or #import "XYConfig.h". Where the header genuinely varies per build, select it with #if over literal includes rather than by expanding a macro into the operand.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved