From b171c930622940ff822b993fb2517d9977cb73bc Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 4 Oct 2026 01:10:30 +0000 Subject: [PATCH 1/2] Fix compiler_assert macro and time_t redefinition - Replace legacy compiler_assert switch macro with C++11 static_assert in utility.h - Include time.h and add preprocessor guard around manual time_t typedef in tu_types.h - Add _CRT_SECURE_NO_WARNINGS and _CRT_NONSTDC_NO_WARNINGS MSVC compile definitions in CMakeLists.txt Co-authored-by: ClausValcaTD <193546948+ClausValcaTD@users.noreply.github.com> --- CMakeLists.txt | 22 +++ third_party/gameswf/base/tu_types.h | 210 ++++++++++++++-------------- third_party/gameswf/base/utility.h | 2 +- 3 files changed, 131 insertions(+), 103 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 611e936..e936f32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,24 @@ if(EXISTS "${GAMESWF_ROOT}/base/utility.h") UTILITY_H_CONTENT "${UTILITY_H_CONTENT}") file(WRITE "${GAMESWF_ROOT}/base/utility.h" "${UTILITY_H_CONTENT}") endif() + if(UTILITY_H_CONTENT MATCHES "switch\\(0\\)\\{case 0: case x:;\\}") + string(REPLACE + "#define compiler_assert(x)\tswitch(0){case 0: case x:;}" + "#define compiler_assert(x)\tstatic_assert((x), \"compiler_assert failed\")" + UTILITY_H_CONTENT "${UTILITY_H_CONTENT}") + file(WRITE "${GAMESWF_ROOT}/base/utility.h" "${UTILITY_H_CONTENT}") + endif() +endif() + +if(EXISTS "${GAMESWF_ROOT}/base/tu_types.h") + file(READ "${GAMESWF_ROOT}/base/tu_types.h" TU_TYPES_H_CONTENT) + if(NOT TU_TYPES_H_CONTENT MATCHES "_TIME_T_DEFINED") + string(REPLACE + "#include " + "#include \n#include \n\n#if !defined(_MSC_VER) && !defined(_TIME_T_DEFINED) && !defined(__time_t_defined)\ntypedef long time_t;\n#define _TIME_T_DEFINED\n#endif" + TU_TYPES_H_CONTENT "${TU_TYPES_H_CONTENT}") + file(WRITE "${GAMESWF_ROOT}/base/tu_types.h" "${TU_TYPES_H_CONTENT}") + endif() endif() if(EXISTS "${GAMESWF_ROOT}/gameswf/gameswf_environment.h") @@ -214,6 +232,10 @@ target_compile_definitions(gameswf_core PUBLIC if(MSVC) target_compile_options(gameswf_core PRIVATE /W3 /O2 /GR-) + target_compile_definitions(gameswf_core PRIVATE + _CRT_SECURE_NO_WARNINGS + _CRT_NONSTDC_NO_WARNINGS + ) else() target_compile_options(gameswf_core PRIVATE -fPIC -w -O3 -fno-rtti) endif() diff --git a/third_party/gameswf/base/tu_types.h b/third_party/gameswf/base/tu_types.h index 8be3c5c..efb7bc5 100644 --- a/third_party/gameswf/base/tu_types.h +++ b/third_party/gameswf/base/tu_types.h @@ -1,102 +1,108 @@ -// tu_types.h -- Ignacio CastaÒo, Thatcher Ulrich 2003 - -// This source code has been donated to the Public Domain. Do -// whatever you want with it. - -// Minimal typedefs. Follows SDL conventions; falls back on SDL.h if -// platform isn't obvious. - - -#ifndef TU_TYPES_H -#define TU_TYPES_H - - -#include "base/tu_config.h" -#include - - -#if defined(__i386__) || defined(_WIN32) || defined(__GNUC__) - - // On known little-endian platforms, define this stuff. - #define _TU_LITTLE_ENDIAN_ 1 - - #ifdef TU_USE_SDL - # ifndef _SDL_stdinc_h - typedef unsigned char Uint8; - typedef signed char Sint8; - typedef unsigned short Uint16; - typedef short Sint16; - typedef unsigned int Uint32; - typedef int Sint32; - # endif - #else - # ifndef Uint8 - typedef unsigned char Uint8; - typedef signed char Sint8; - typedef unsigned short Uint16; - typedef short Sint16; - typedef unsigned int Uint32; - typedef int Sint32; - # endif - #endif - - #ifndef _MSC_VER - // Probably gcc or something compatible - typedef unsigned long long Uint64; - typedef long long Sint64; - #else // _MSC_VER - typedef unsigned __int64 Uint64; - typedef __int64 Sint64; - #endif // _MSC_VER - -#else // not __I386__ and not _WIN32 - - // On unknown platforms, rely on SDL - #include - - #if SDL_BYTEORDER == SDL_LIL_ENDIAN - #define _TU_LITTLE_ENDIAN_ 1 - #else - #undef _TU_LITTLE_ENDIAN_ - #endif // SDL_BYTEORDER == SDL_LIL_ENDIAN - -#endif // not __I366__ and not _WIN32 - - -typedef Uint8 uint8; -typedef Sint8 sint8; -typedef Sint8 int8; -typedef Uint16 uint16; -typedef Sint16 sint16; -typedef Sint16 int16; -typedef Uint32 uint32; -typedef Sint32 sint32; -typedef Sint32 int32; -typedef Uint64 uint64; -typedef Sint64 sint64; -typedef Sint64 int64; - -#if TU_USES_FLOAT_AS_COORDINATE_COMPONENT - typedef float coord_component; -#else - typedef Sint16 coord_component; -#endif - - -// A function to run some validation checks. -#ifdef _WIN32 -__declspec(dllexport) bool tu_types_validate(); -#else // _WIN32 -bool tu_types_validate(); -#endif - - -#endif // TU_TYPES_H - - -// Local Variables: -// mode: C++ -// c-basic-offset: 8 -// tab-width: 8 -// indent-tabs-mode: t -// End: +// tu_types.h -- Ignacio CastaÒo, Thatcher Ulrich 2003 + +// This source code has been donated to the Public Domain. Do +// whatever you want with it. + +// Minimal typedefs. Follows SDL conventions; falls back on SDL.h if +// platform isn't obvious. + + +#ifndef TU_TYPES_H +#define TU_TYPES_H + + +#include "base/tu_config.h" +#include +#include + +#if !defined(_MSC_VER) && !defined(_TIME_T_DEFINED) && !defined(__time_t_defined) +typedef long time_t; +#define _TIME_T_DEFINED +#endif + + +#if defined(__i386__) || defined(_WIN32) || defined(__GNUC__) + + // On known little-endian platforms, define this stuff. + #define _TU_LITTLE_ENDIAN_ 1 + + #ifdef TU_USE_SDL + # ifndef _SDL_stdinc_h + typedef unsigned char Uint8; + typedef signed char Sint8; + typedef unsigned short Uint16; + typedef short Sint16; + typedef unsigned int Uint32; + typedef int Sint32; + # endif + #else + # ifndef Uint8 + typedef unsigned char Uint8; + typedef signed char Sint8; + typedef unsigned short Uint16; + typedef short Sint16; + typedef unsigned int Uint32; + typedef int Sint32; + # endif + #endif + + #ifndef _MSC_VER + // Probably gcc or something compatible + typedef unsigned long long Uint64; + typedef long long Sint64; + #else // _MSC_VER + typedef unsigned __int64 Uint64; + typedef __int64 Sint64; + #endif // _MSC_VER + +#else // not __I386__ and not _WIN32 + + // On unknown platforms, rely on SDL + #include + + #if SDL_BYTEORDER == SDL_LIL_ENDIAN + #define _TU_LITTLE_ENDIAN_ 1 + #else + #undef _TU_LITTLE_ENDIAN_ + #endif // SDL_BYTEORDER == SDL_LIL_ENDIAN + +#endif // not __I366__ and not _WIN32 + + +typedef Uint8 uint8; +typedef Sint8 sint8; +typedef Sint8 int8; +typedef Uint16 uint16; +typedef Sint16 sint16; +typedef Sint16 int16; +typedef Uint32 uint32; +typedef Sint32 sint32; +typedef Sint32 int32; +typedef Uint64 uint64; +typedef Sint64 sint64; +typedef Sint64 int64; + +#if TU_USES_FLOAT_AS_COORDINATE_COMPONENT + typedef float coord_component; +#else + typedef Sint16 coord_component; +#endif + + +// A function to run some validation checks. +#ifdef _WIN32 +__declspec(dllexport) bool tu_types_validate(); +#else // _WIN32 +bool tu_types_validate(); +#endif + + +#endif // TU_TYPES_H + + +// Local Variables: +// mode: C++ +// c-basic-offset: 8 +// tab-width: 8 +// indent-tabs-mode: t +// End: diff --git a/third_party/gameswf/base/utility.h b/third_party/gameswf/base/utility.h index 2e8ed77..2b5a86e 100644 --- a/third_party/gameswf/base/utility.h +++ b/third_party/gameswf/base/utility.h @@ -53,7 +53,7 @@ // Compile-time assert. Thanks to Jon Jagger // (http://www.jaggersoft.com) for this trick. -#define compiler_assert(x) switch(0){case 0: case x:;} +#define compiler_assert(x) static_assert((x), "compiler_assert failed") // From 837619d719b631db4fd2ed2c46298544e4a38aa1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 4 Oct 2026 01:35:46 +0000 Subject: [PATCH 2/2] Fix cross-platform build failures across macOS, Windows, and WebAssembly - Replace compiler_assert macro with C++11 static_assert in utility.h - Add preprocessor guards for time_t in tu_types.h - Add MSVC CRT definitions and _TIME_T in CMakeLists.txt - Add APPLE target link options for libretro_flash in CMakeLists.txt Co-authored-by: ClausValcaTD <193546948+ClausValcaTD@users.noreply.github.com> --- CMakeLists.txt | 16 +++++----------- third_party/gameswf/base/tu_types.h | 3 ++- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e936f32..a8ac9c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,17 +82,6 @@ if(EXISTS "${GAMESWF_ROOT}/base/utility.h") endif() endif() -if(EXISTS "${GAMESWF_ROOT}/base/tu_types.h") - file(READ "${GAMESWF_ROOT}/base/tu_types.h" TU_TYPES_H_CONTENT) - if(NOT TU_TYPES_H_CONTENT MATCHES "_TIME_T_DEFINED") - string(REPLACE - "#include " - "#include \n#include \n\n#if !defined(_MSC_VER) && !defined(_TIME_T_DEFINED) && !defined(__time_t_defined)\ntypedef long time_t;\n#define _TIME_T_DEFINED\n#endif" - TU_TYPES_H_CONTENT "${TU_TYPES_H_CONTENT}") - file(WRITE "${GAMESWF_ROOT}/base/tu_types.h" "${TU_TYPES_H_CONTENT}") - endif() -endif() - if(EXISTS "${GAMESWF_ROOT}/gameswf/gameswf_environment.h") file(READ "${GAMESWF_ROOT}/gameswf/gameswf_environment.h" ENV_H_CONTENT) if(ENV_H_CONTENT MATCHES "private array") @@ -235,6 +224,7 @@ if(MSVC) target_compile_definitions(gameswf_core PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS + _TIME_T ) else() target_compile_options(gameswf_core PRIVATE -fPIC -w -O3 -fno-rtti) @@ -308,6 +298,10 @@ else() target_compile_options(libretro_flash PRIVATE -fPIC -Wall -Wextra -O3 -fno-exceptions -fno-rtti) endif() +if(APPLE) + target_link_options(libretro_flash PRIVATE "-Wl,-undefined,dynamic_lookup") +endif() + # Unit Test Executable - Input Subsystem add_executable(test_input tests/test_input.cpp src/input_manager.cpp) target_include_directories(test_input PRIVATE include) diff --git a/third_party/gameswf/base/tu_types.h b/third_party/gameswf/base/tu_types.h index efb7bc5..47b6860 100644 --- a/third_party/gameswf/base/tu_types.h +++ b/third_party/gameswf/base/tu_types.h @@ -15,9 +15,10 @@ #include #include -#if !defined(_MSC_VER) && !defined(_TIME_T_DEFINED) && !defined(__time_t_defined) +#if !defined(_MSC_VER) && !defined(_TIME_T_DEFINED) && !defined(__time_t_defined) && !defined(_TIME_T) && !defined(_TIME_T_DECLARED) && !defined(__DEFINED_time_t) typedef long time_t; #define _TIME_T_DEFINED +#define _TIME_T #endif