OSX build fixes, again...

This commit is contained in:
tamasmeszaros 2018-05-22 15:13:07 +02:00
parent 73b861287c
commit 9c2d9b2ba3
3 changed files with 24 additions and 18 deletions

View File

@ -2,6 +2,10 @@
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON) 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. # Add our own cmake module path.
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/)

View File

@ -16,14 +16,12 @@
#include <agg/agg_path_storage.h> #include <agg/agg_path_storage.h>
// For png compression // For png compression
#if !defined(__linux__) || \ //#if !((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE)
(defined(__linux__) && ((_POSIX_C_SOURCE >= 200112L || \ //inline char *strerror_r(int errnum, char *buf, size_t buflen) {
_XOPEN_SOURCE >= 600) && ! _GNU_SOURCE)) // strerror_s(buf, buflen, errnum);
inline char *strerror_r(int errnum, char *buf, size_t buflen) { // return buf;
strerror_s(buf, buflen, errnum); //}
return buf; //#endif
}
#endif
#include <png/writer.hpp> #include <png/writer.hpp>
namespace Slic3r { namespace Slic3r {
@ -133,6 +131,10 @@ Raster::Raster(Raster &&m):
void Raster::reset(const Raster::Resolution &r, const Raster::PixelDim &pd) 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)); impl_.reset(new Impl(r, pd));
} }

View File

@ -96,18 +96,18 @@ namespace png
#define ERRBUF_SIZE 512 #define ERRBUF_SIZE 512
char buf[ERRBUF_SIZE] = { 0 }; char buf[ERRBUF_SIZE] = { 0 };
#ifdef HAVE_STRERROR_S //#ifdef HAVE_STRERROR_S
strerror_s(buf, ERRBUF_SIZE, errnum); strerror_s(buf, ERRBUF_SIZE, errnum);
return std::string(buf); return std::string(buf);
#else //#else
#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE //#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE
strerror_r(errnum, buf, ERRBUF_SIZE); // strerror_r(errnum, buf, ERRBUF_SIZE);
return std::string(buf); // return std::string(buf);
#else //#else
/* GNU variant can return a pointer to static buffer instead of buf */ // /* GNU variant can return a pointer to static buffer instead of buf */
return std::string(strerror_r(errnum, buf, ERRBUF_SIZE)); // return std::string(strerror_r(errnum, buf, ERRBUF_SIZE));
#endif //#endif
#endif //#endif
#undef ERRBUF_SIZE #undef ERRBUF_SIZE
} }