windows: fix MinGW-w64 build of win_file.c#4987
Open
hjiawei wants to merge 1 commit into
Open
Conversation
cb8e0c7 to
08815b6
Compare
Two issues prevent core/shared/platform/windows/win_file.c from
compiling with the MinGW-w64 (GCC) toolchain:
- The include of "PathCch.h" fails on a case-sensitive filesystem; the
MinGW SDK installs the header lowercase (pathcch.h).
- Three // comments in os_readlinkat() end with a backslash ("\??\").
GCC treats a backslash at the end of a // comment line as a line
continuation, so the following line of code is swallowed into the
comment and the function fails to parse. MSVC does not. Append a word
to each so the comment no longer ends in a backslash, keeping the
documented NT paths intact.
The enclosing if/else-if block is reformatted (brace placement and
indentation) to keep the modified lines clang-format clean.
Signed-off-by: Jiawei Huang <jiawei@tigera.io>
08815b6 to
b2a0326
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
core/shared/platform/windows/win_file.cdoes not compile with the MinGW-w64 (GCC) toolchain, which WAMR documents as a supported Windows toolchain. Two issues:Header case.
#include "PathCch.h"fails on a case-sensitive filesystem (e.g. cross-compiling from Linux); the MinGW SDK installs the header lowercase aspathcch.h. Lowercasing the include is a no-op on the case-insensitive Windows filesystem MSVC uses.Comment line-continuation. Three
//comments inos_readlinkat()end with a backslash (\??\). GCC treats a backslash at the end of a//comment line as a line continuation, so the following line of code is spliced into the comment and the function fails to parse (-Wcomment: multi-line comment, then a cascade of syntax errors). MSVC does not do this. Appending a trailing word to each comment so it no longer ends in a backslash removes the hazard while keeping the documented NT paths intact (and matches the existing style of the nearby// ... \??\<drive>:\ as a symlink.comment).Neither change alters behavior; both are inert for the MSVC build.
The enclosing
if/else ifblock is also reformatted — brace placement, indentation, and reflowing the one comment that exceeded the column limit — so the modified lines pass theclang-formatcheck. That part of the diff is whitespace/comment-only.Testing
Verified by cross-compiling a project that bundles WAMR (Fluent Bit) for Windows from Linux with the Fedora MinGW-w64 UCRT toolchain:
vmlib/win_file.ccompile and link into a workingfluent-bit.exe(PE32+ x86-64).git clang-format(clang-format-14) reports the changed lines clean.