Skip to content

build: define YY_NO_UNISTD_H only for MSVC#280

Open
hjiawei wants to merge 1 commit into
fluent:masterfrom
hjiawei:mingw-cross-build
Open

build: define YY_NO_UNISTD_H only for MSVC#280
hjiawei wants to merge 1 commit into
fluent:masterfrom
hjiawei:mingw-cross-build

Conversation

@hjiawei

@hjiawei hjiawei commented Jul 6, 2026

Copy link
Copy Markdown

YY_NO_UNISTD_H is currently defined for all Windows targets to keep the flex-generated lexer from including <unistd.h>. That's correct for MSVC, which has no unistd.h, but wrong for MinGW-w64: MinGW ships a real unistd.h, and suppressing it leaves the generated lexer without a declaration of isatty(), which GCC 14 and later reject as an implicit function declaration (an error by default).

Gate the definition on MSVC so MinGW builds get the real unistd.h. No change for MSVC.

Testing

Verified by cross-compiling Fluent Bit (which bundles cmetrics) for Windows from Linux with the Fedora MinGW-w64 UCRT toolchain: the cmetrics prometheus decode lexer compiles instead of failing on the implicit isatty declaration. MSVC builds are unaffected — the definition still applies there.

MinGW provides a real unistd.h, and suppressing it leaves the flex
generated lexer without a declaration of isatty(), which GCC 14 and
later reject as an implicit function declaration. Keep the suppression
for MSVC, which has no unistd.h.

Signed-off-by: Jiawei Huang <jiawei@tigera.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant