Repository navigation
build(mingw): Fix the strtok_r declaration conflict with MinGW-w64 when building without precompiled headers - #3693
Conversation
…en building without precompiled headers
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. WalkthroughThe Changesstrtok_r Header
Estimated code review effort: 1 (Trivial) | ~3 minutes Change: Bug fix Suggested labels: Suggested reviewers: Merge Risk:
|
[Low impact] The PR appears safe to merge.
|
|
|
||
| #pragma once | ||
|
|
||
| // TheSuperHackers @build OmarAglan 16/11/2026 Include string.h first so that the C linkage declaration of strtok_r in MinGW-w64 comes before this one. |
This was the only error. I did built both games with MinGW-w64 and -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON in Release and Debug, and both compile and link. Two other parts fail on MinGW-w64 with precompiled headers on as well, so they are not part of this:
CI does not build either of them. The MinGW-w64 tools are disabled in the toolchain file because they need MFC. #3523 was found with the Docker build. That build uses VC6 under Wine with precompiled headers disabled. VC6 does not declare strtok_r in string.h, so the conflict cannot happen there. The MSVC and VC6 CI jobs have built without precompiled headers since #3608. MinGW-w64 was not built without precompiled headers before #3677 |
Instead of copy-paste my review comment into an AI and copy-paste the response back, maybe read the actual response. If I understand correctly, there ARE more issues, that are not being fixed here. |

MinGW-w64 declares
strtok_rinstring.hwith C linkage.WWLib/strtok_r.hdeclares it again withoutextern "C".With precompiled headers,
string.his always included first, and the later declaration is accepted. Without precompiled headers,strtok_r.cppincludesstrtok_r.hbeforestring.h, and GCC stops with:This change includes
string.hat the top ofstrtok_r.h, so the MinGW-w64 declaration always comes first. MSVC does not declarestrtok_r, so nothing changes there.#3677 builds MinGW-w64 without precompiled headers, so it needs this change. I built both games locally with MinGW-w64 and
-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON. This was the only error.AI USE
I used Claude Code to find the cause, make the change and test the build. I reviewed the change.