From c317e604c6b94993f95bbf89b55ab673de74debb Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 4 Jun 2024 09:30:54 +0200 Subject: [PATCH] Improve minizconf.h; in CMake, don't use C++-compilerflags for plain C --- neo/CMakeLists.txt | 6 +++--- neo/framework/miniz/minizconf.h | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 2eb2c21f..42228f34 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -362,20 +362,20 @@ if(D3_COMPILER_IS_GCC_OR_CLANG) CHECK_CXX_COMPILER_FLAG("-Woverloaded-virtual" cxx_has_Woverload_virtual) if(cxx_has_Woverload_virtual) - add_compile_options(-Woverloaded-virtual) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual") endif() # shut up about using memcpy() on classes, in the cases doom3 uses it it seems to be fine CHECK_CXX_COMPILER_FLAG("-Wno-class-memaccess" cxx_has_Wno-class-memaccess) if(cxx_has_Wno-class-memaccess) - add_compile_options(-Wno-class-memaccess) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess") endif() # ignore warnings about variables named "requires" for now (in C++20 it's a keyword, # but currently we don't even use C++11 features) CHECK_CXX_COMPILER_FLAG("-Wno-c++20-compat" cxx_has_Wno-cpp20-compat) if(cxx_has_Wno-cpp20-compat) - add_compile_options(-Wno-c++20-compat) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++20-compat") endif() if(AROS) diff --git a/neo/framework/miniz/minizconf.h b/neo/framework/miniz/minizconf.h index 708762ba..b9fa5779 100644 --- a/neo/framework/miniz/minizconf.h +++ b/neo/framework/miniz/minizconf.h @@ -34,18 +34,22 @@ #ifndef COMMON_UNZIP_MINIZCONF_H #define COMMON_UNZIP_MINIZCONF_H -#ifndef OF - #define OF(args) args +#ifndef z_off_t + #if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) + #include + #define z_off_t off_t + #elif defined(off_t) // maybe we're lucky :-p + #define z_off_t off_t + #else + #define z_off_t long + #endif #endif #ifndef ZEXPORT #define ZEXPORT #endif -#ifndef z_off_t - #define z_off_t long -#endif - +// FIXME: why not just set this to int64_t? #if !defined(_WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #else @@ -56,4 +60,8 @@ # endif #endif +#if defined(__cplusplus) && __cplusplus >= 201103L +static_assert( sizeof(z_off64_t) == 8, "z_off64_t should be a 64bit type" ); +#endif + #endif