Skip to content

Fix MinGW build: Replace unsupported %zu format with %llu#3059

Open
ayaz2004 wants to merge 2 commits intogoogle-deepmind:mainfrom
ayaz2004:fix-mingw-format-specifier
Open

Fix MinGW build: Replace unsupported %zu format with %llu#3059
ayaz2004 wants to merge 2 commits intogoogle-deepmind:mainfrom
ayaz2004:fix-mingw-format-specifier

Conversation

@ayaz2004
Copy link

@ayaz2004 ayaz2004 commented Jan 28, 2026

Summary: This PR fixes a compilation error when building with MinGW-w64. The compiler treats %zu as an unknown format specifier because it defaults to checking against MSVCRT compatibility, where %z is not supported in older runtimes.

Bug: When compiling src/thread/thread_pool.cc with MinGW, the following error occurs:
src/thread/thread_pool.cc:202:47: error: unknown conversion type character ‘z’ in format [-Werror=format=]
mju_error("Arena is not large enough for %zu shards", number_of_shards);

Fix: Replaced %zu with %llu and cast the corresponding arguments to unsigned long long. This ensures the format string is valid across all platforms (Windows/MinGW, MSVC, Linux, macOS) without relying on C99 runtime support for %z.

Verification: I have verified that this change fixes the build error on a Windows 11 machine using the MinGW64 toolchain.

@google-cla
Copy link

google-cla bot commented Jan 28, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@ayaz2004 ayaz2004 closed this Jan 28, 2026
@ayaz2004 ayaz2004 deleted the fix-mingw-format-specifier branch January 28, 2026 22:32
@ayaz2004 ayaz2004 restored the fix-mingw-format-specifier branch January 28, 2026 22:32
@ayaz2004 ayaz2004 reopened this Jan 28, 2026
Copy link

@maximilian-maisel-bl maximilian-maisel-bl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested on Linux and Windows with gcc and the testspeed sample.

@maximilian-maisel-bl
Copy link

Looks good to me now.

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.

2 participants