Skip to content

Commit 19db166

Browse files
committed
Fix Windows compile errors in plug-and-play: missing windows.h, coroutine guard, -fcoroutines
- Processing.h: explicitly include <windows.h> and <shellapi.h> on Windows before any Win32 API usage. Previously relied on <GL/glew.h> pulling it in transitively, which broke when compiling Processing.cpp directly via run.bat (WIN32_FIND_DATAA, HANDLE, MessageBoxA, AllocConsole etc. all undeclared). - Processing.h: guard <coroutine> with __cpp_impl_coroutine feature-test macro -- GCC 16 made -fcoroutines mandatory and errors without it. - generate_plugandplay.py: add -fcoroutines to all Windows g++ invocations in run.bat template so coroutines work when user sketches need them. - Regenerated processing-cpp-plugandplay.zip
1 parent 0ec0db4 commit 19db166

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

625 Bytes
Binary file not shown.

scripts/generate_plugandplay.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,9 @@ def generate(out_dir: Path) -> None:
596596
597597
if %NEED_ENGINE_BUILD%==1 (
598598
echo Compiling engine ^(first run; ~10-15s^)...
599-
call :run_build_step "engine compile" g++ -std=c++17 -O2 -c -I"%ENGINE_DIR%include" %DEFINES% "%ENGINE_DIR%src\\Processing.cpp" -o "%LIB_DIR%\\Processing.o"
599+
call :run_build_step "engine compile" g++ -std=c++17 -fcoroutines -O2 -c -I"%ENGINE_DIR%include" %DEFINES% "%ENGINE_DIR%src\\Processing.cpp" -o "%LIB_DIR%\\Processing.o"
600600
if errorlevel 1 exit /b 1
601-
call :run_build_step "engine compile" g++ -std=c++17 -O2 -c -I"%ENGINE_DIR%include" %DEFINES% "%ENGINE_DIR%src\\Processing_defaults.cpp" -o "%LIB_DIR%\\Processing_defaults.o"
601+
call :run_build_step "engine compile" g++ -std=c++17 -fcoroutines -O2 -c -I"%ENGINE_DIR%include" %DEFINES% "%ENGINE_DIR%src\\Processing_defaults.cpp" -o "%LIB_DIR%\\Processing_defaults.o"
602602
if errorlevel 1 exit /b 1
603603
ar rcs "%LIB_A%" "%LIB_DIR%\\Processing.o" "%LIB_DIR%\\Processing_defaults.o"
604604
del "%LIB_DIR%\\Processing.o" "%LIB_DIR%\\Processing_defaults.o"
@@ -616,11 +616,11 @@ def generate(out_dir: Path) -> None:
616616
REM by actually building this package and checking with the
617617
REM -Winvalid-pch warning flag -- it's not a build failure, the
618618
REM caching just quietly stops working).
619-
call :run_build_step "header precompile" g++ -std=c++17 -I"%ENGINE_DIR%include" %DEFINES% -pthread -x c++-header "%ENGINE_DIR%include\\Processing.h" -o "%PCH_FILE%"
619+
call :run_build_step "header precompile" g++ -std=c++17 -fcoroutines -I"%ENGINE_DIR%include" %DEFINES% -pthread -x c++-header "%ENGINE_DIR%include\\Processing.h" -o "%PCH_FILE%"
620620
if errorlevel 1 exit /b 1
621621
)
622622
623-
call :run_build_step "sketch compile" g++ -std=c++17 -I"%ENGINE_DIR%include" %DEFINES% %SOURCES% -L"%LIB_DIR%" -lprocessing_cpp -lglfw3 -lglew32 -lopengl32 -lglu32 -lcomdlg32 -lshell32 -lole32 -luuid -mwindows -pthread -o "%PROJECT_DIR%\\.processing-cpp-build.exe"
623+
call :run_build_step "sketch compile" g++ -std=c++17 -fcoroutines -I"%ENGINE_DIR%include" %DEFINES% %SOURCES% -L"%LIB_DIR%" -lprocessing_cpp -lglfw3 -lglew32 -lopengl32 -lglu32 -lcomdlg32 -lshell32 -lole32 -luuid -mwindows -pthread -o "%PROJECT_DIR%\\.processing-cpp-build.exe"
624624
if errorlevel 1 exit /b 1
625625
626626
echo Running...

src/Processing.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,29 @@
88
# include "stb_truetype.h"
99
# endif
1010
#endif
11+
// On Windows, include <windows.h> explicitly before anything else that needs
12+
// Win32 APIs (FindFirstFileA, MessageBoxA, AllocConsole, Sleep, etc.).
13+
// <GL/glew.h> pulls it in transitively but only after GLEW's own includes --
14+
// explicit include here guarantees it arrives before any Win32 API usage.
15+
#ifdef _WIN32
16+
# ifndef WIN32_LEAN_AND_MEAN
17+
# define WIN32_LEAN_AND_MEAN
18+
# endif
19+
# ifndef NOMINMAX
20+
# define NOMINMAX
21+
# endif
22+
# include <windows.h>
23+
# include <shellapi.h>
24+
#endif
1125
#ifndef _WIN32
1226
#include <dirent.h>
1327
#endif
1428
#include <functional>
29+
// <coroutine> requires -fcoroutines on GCC; guard it so the header compiles
30+
// without that flag when coroutines aren't needed by the user's sketch.
31+
#if defined(__cpp_impl_coroutine) || defined(__clang__) || defined(_MSC_VER) || (defined(__GNUC__) && defined(_GLIBCXX_COROUTINE))
1532
#include <coroutine>
33+
#endif
1634
// =============================================================================
1735
// Processing.h -- processing-cpp API
1836
// =============================================================================

0 commit comments

Comments
 (0)