diff --git a/xs/CMakeLists.txt b/xs/CMakeLists.txt index 3b9a53d5b..2669f67ef 100644 --- a/xs/CMakeLists.txt +++ b/xs/CMakeLists.txt @@ -2,6 +2,10 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +# Enable C11 language standard. +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) + # Add our own cmake module path. list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/) diff --git a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp index f1eee42f5..ab83c5ec6 100644 --- a/xs/src/libslic3r/Rasterizer/Rasterizer.cpp +++ b/xs/src/libslic3r/Rasterizer/Rasterizer.cpp @@ -16,14 +16,12 @@ #include // For png compression -#if !defined(__linux__) || \ - (defined(__linux__) && ((_POSIX_C_SOURCE >= 200112L || \ - _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE)) -inline char *strerror_r(int errnum, char *buf, size_t buflen) { - strerror_s(buf, buflen, errnum); - return buf; -} -#endif +//#if !((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) +//inline char *strerror_r(int errnum, char *buf, size_t buflen) { +// strerror_s(buf, buflen, errnum); +// return buf; +//} +//#endif #include namespace Slic3r { @@ -133,6 +131,10 @@ Raster::Raster(Raster &&m): void Raster::reset(const Raster::Resolution &r, const Raster::PixelDim &pd) { + // Free up the unneccessary memory and make sure it stays clear after + // an exception + impl_.reset(); + impl_.reset(new Impl(r, pd)); } diff --git a/xs/src/png/error.hpp b/xs/src/png/error.hpp index 834cf1b3a..f7d6d7b5f 100644 --- a/xs/src/png/error.hpp +++ b/xs/src/png/error.hpp @@ -96,18 +96,18 @@ namespace png #define ERRBUF_SIZE 512 char buf[ERRBUF_SIZE] = { 0 }; -#ifdef HAVE_STRERROR_S +//#ifdef HAVE_STRERROR_S strerror_s(buf, ERRBUF_SIZE, errnum); return std::string(buf); -#else -#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE - strerror_r(errnum, buf, ERRBUF_SIZE); - return std::string(buf); -#else - /* GNU variant can return a pointer to static buffer instead of buf */ - return std::string(strerror_r(errnum, buf, ERRBUF_SIZE)); -#endif -#endif +//#else +//#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE +// strerror_r(errnum, buf, ERRBUF_SIZE); +// return std::string(buf); +//#else +// /* GNU variant can return a pointer to static buffer instead of buf */ +// return std::string(strerror_r(errnum, buf, ERRBUF_SIZE)); +//#endif +//#endif #undef ERRBUF_SIZE }