Skip to content

build(mingw): Fix the strtok_r declaration conflict with MinGW-w64 when building without precompiled headers - #3693

Open
OmarAglan wants to merge 2 commits into
TheSuperHackers:mainfrom
OmarAglan:build/mingw-strtok-r-declaration
Open

OmarAglan wants to merge 2 commits into
TheSuperHackers:mainfrom
OmarAglan:build/mingw-strtok-r-declaration

Conversation

@OmarAglan

Copy link
Copy Markdown

MinGW-w64 declares strtok_r in string.h with C linkage. WWLib/strtok_r.h declares it again without extern "C".

With precompiled headers, string.h is always included first, and the later declaration is accepted. Without precompiled headers, strtok_r.cpp includes strtok_r.h before string.h, and GCC stops with:

string.h: error: conflicting declaration of 'char* strtok_r(char*, const char*, char**)' with 'C' linkage
strtok_r.h:40: note: previous declaration with 'C++' linkage

This change includes string.h at the top of strtok_r.h, so the MinGW-w64 declaration always comes first. MSVC does not declare strtok_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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T09:35:18.907814Z d0640d5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The strtok_r.h header now includes <string.h>. No declarations or other behavior changed.

Changes

strtok_r Header

Layer / File(s) Summary
Add string header include
Core/Libraries/Source/WWVegas/WWLib/strtok_r.h
The header adds <string.h>. No declarations or other behavior changed.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Suggested labels: Build, CompileBug, Fix

Suggested reviewers: skyaero42, xezon

Merge Risk: Minimal · up to d0640

This adds a standard header include so that MinGW-w64 builds without precompiled headers no longer hit the conflicting strtok_r declaration. It does not change behavior on other toolchains, and I found no remaining merge risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: adding a fix for the strtok_r declaration conflict with MinGW-w64 when building without precompiled headers. The raw summary confirms the only change is adding string.…
Description check Passed The description explains the cause: MinGW-w64 declares strtok_r in string.h with C linkage, while WWLib/strtok_r.h declares it again without extern "C". It gives the GCC error, states that including s…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: adding a fix for the strtok_r declaration conflict with MinGW-w64 when building without precompiled headers. The raw summary confirms the only change is adding string.h to WWLib/strtok_r.h, which matches the title's scope. The title is a single sentence, specific, and uses the conventional build(mingw) prefix.

Full details: Description check

Explanation

The description explains the cause: MinGW-w64 declares strtok_r in string.h with C linkage, while WWLib/strtok_r.h declares it again without extern "C". It gives the GCC error, states that including string.h first resolves the conflict, notes MSVC is unaffected, and describes the local build test with precompiled headers disabled. It directly matches the one-file change.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6032501d-47e3-4e75-80aa-73c78df8bca7
Commits

Reviewing files that changed from the base of the PR and between 8125684 and d0640d5.

Files selected for processing: 1

  • Core/Libraries/Source/WWVegas/WWLib/strtok_r.h
Files with no reviewable changes: 1

  • Core/Libraries/Source/WWVegas/WWLib/strtok_r.h

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Adds <string.h> before the declaration of strtok_r, so MinGW-w64 sees its C linkage declaration first when building without precompiled headers.

  • MinGW-w64 builds can use strtok_r.h without precompiled headers.

Reviews (2) · Last reviewed commit: "Remove the comment" · Reviewed by Greptile

@Skyaero42 Skyaero42 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Rather than fixing one thing at a time, I would rather see everything fixed when pre-compiled headers are off.

Why was this not found earlier when #3523 was fixed? Wouldn't it have come up then?


#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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

comment not needed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

removed

@OmarAglan

Copy link
Copy Markdown
Author

Rather than fixing one thing at a time, I would rather see everything fixed when pre-compiled headers are off.

Why was this not found earlier when #3523 was fixed? Wouldn't it have come up then?

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:

  • The Profile build fails in profile_funclevel.cpp, because it uses MSVC __asm blocks.
  • The extras fail because of MSVC link flags, MFC/ATL and min/max macros.

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

@Skyaero42

Copy link
Copy Markdown

Two other parts fail on MinGW-w64 with precompiled headers on as well, so they are not part of this:

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.

@OmarAglan

OmarAglan commented Nov 17, 2026 •

Copy link
Copy Markdown
Author

Two other parts fail on MinGW-w64 with precompiled headers on as well, so they are not part of this:

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.

although i used ai to fix my Grammer and spelling errors:
image
i do write the whole thing my self

maybe the comment above is confusing, sorry about that

note that the profile and the extras build also fail on MinGW with precompiled headers on, that's old MinGW problem and not caused by this, the ci don't build them on MinGW

i could open another pr that target that issues, but it outside the scope of this change.

edit:
from here on, i will write everything myself with no ai rewriting the same thing, even if its bad grammar.

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