Skip to content

Commit 2d9c6d9

Browse files
committed
Document sync_with_stdio fix to prevent future MinGW iostream crashes
1 parent 3fddac4 commit 2d9c6d9

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/Processing.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3344,7 +3344,11 @@ void PApplet::run(){
33443344
PDEBUG("Debug mode ON -- PApplet::run() starting\n");
33453345
g_papplet = this;
33463346
#ifdef _WIN32
3347-
// Prevent ios_base crash on Windows by syncing before first use
3347+
// CRITICAL: call sync_with_stdio before ANY iostream use on Windows.
3348+
// MinGW 14+ has a bug where ios_base::_M_init crashes when the first
3349+
// std::cerr/cout use happens without a console attached (-mwindows).
3350+
// sync_with_stdio(false) bypasses the broken locale init path.
3351+
// DO NOT add any std::cerr/cout calls before PApplet::run() is called.
33483352
::std::ios_base::sync_with_stdio(false);
33493353
::std::cin.tie(nullptr);
33503354
#endif

0 commit comments

Comments
 (0)