getting rid of strerror problem

This commit is contained in:
tamasmeszaros 2018-05-22 16:39:47 +02:00
parent 9c2d9b2ba3
commit 2eddacfb7e
3 changed files with 19 additions and 18 deletions

View file

@ -1342,7 +1342,7 @@ public:
inline unsigned layers() const { return layers_rst_.size(); }
inline void drawPolygon(const ExPolygon& p, unsigned lyr) {
assert(lyr_id < layers_rst_.size());
assert(lyr < layers_rst_.size());
layers_rst_[lyr].first.draw(p);
}

View file

@ -16,12 +16,6 @@
#include <agg/agg_path_storage.h>
// For png compression
//#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 <png/writer.hpp>
namespace Slic3r {

View file

@ -94,20 +94,27 @@ namespace png
static std::string thread_safe_strerror(int errnum)
{
#define ERRBUF_SIZE 512
char buf[ERRBUF_SIZE] = { 0 };
//#ifdef HAVE_STRERROR_S
#ifdef HAVE_STRERROR_S
char buf[ERRBUF_SIZE] = { 0 };
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
char buf[ERRBUF_SIZE] = { 0 };
strerror_r(errnum, buf, ERRBUF_SIZE);
return std::string(buf);
#elif _GNU_SOURCE
/* GNU variant can return a pointer to static buffer instead of buf */
char buf[ERRBUF_SIZE] = { 0 };
return std::string(strerror_r(errnum, buf, ERRBUF_SIZE));
#else
return std::string("An error occured with errnum ") +
std::to_string(errnum) +
". Converting to the appropriate error message is disabled"
"in this instance of the png++ library.";
#endif
#endif
#undef ERRBUF_SIZE
}