Skip to content

Commit 02b377e

Browse files
committed
Windows: use main() with SW_HIDE instead of WinMain to fix locale crash
1 parent e2e2b9e commit 02b377e

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

mode/CppMode.jar

25 Bytes
Binary file not shown.

src/java/CppBuild.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,10 @@ private File writeSketchImpl(RunnerListener listener) throws IOException {
15361536
out.append("\n");
15371537
out.append("#ifdef _WIN32\n");
15381538
out.append("#include <windows.h>\n");
1539-
out.append("int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) {\n");
1539+
out.append("int main() {\n");
1540+
out.append(" #ifdef _WIN32\n");
1541+
out.append(" ::ShowWindow(::GetConsoleWindow(), SW_HIDE);\n");
1542+
out.append(" #endif\n");
15401543
out.append(" Processing::Sketch sketch;\n");
15411544
out.append(" sketch.run();\n");
15421545
out.append(" return 0;\n");
@@ -3192,8 +3195,8 @@ else if (!cmd.contains(defaultsCpp.getAbsolutePath()))
31923195
Collections.addAll(cmd,
31933196
"-lglfw3", "-lglew32", "-lopengl32", "-lglu32",
31943197
"-lcomdlg32", "-lshell32", "-lole32", "-luuid",
3195-
"-mwindows", "-pthread", "-D_USE_MATH_DEFINES",
3196-
"-static-libgcc", "-static-libstdc++");
3198+
"-pthread", "-D_USE_MATH_DEFINES",
3199+
"-Wl,--subsystem,windows");
31973200
} else if (mac) {
31983201
// macOS: prefer bundled dylibs shipped with the mode (libs/macos)
31993202
// universal dylibs work on both arm64 and x64.

0 commit comments

Comments
 (0)