From 169aa33d5e8fe440fbbb12fe7201a52c052ebb51 Mon Sep 17 00:00:00 2001 From: Tuomas Tonteri Date: Thu, 30 Mar 2023 15:21:22 +0300 Subject: [PATCH 1/3] Make project compile with clang 11.0.1-2 in Mac --- src/include/OpenImageIO/string_view.h | 2 -- src/include/OpenImageIO/strutil.h | 6 ++++-- src/libOpenImageIO/imagebuf.cpp | 2 +- src/libOpenImageIO/imageinput.cpp | 2 +- src/libOpenImageIO/imageio.cpp | 4 ++-- src/libOpenImageIO/imageoutput.cpp | 2 +- src/libtexture/imagecache.cpp | 2 +- src/libtexture/texturesys.cpp | 2 +- src/libutil/filesystem.cpp | 12 +++++++++++- src/oiiotool/imagerec.cpp | 2 +- 10 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/include/OpenImageIO/string_view.h b/src/include/OpenImageIO/string_view.h index b0df6b8f53..60d3c5487e 100644 --- a/src/include/OpenImageIO/string_view.h +++ b/src/include/OpenImageIO/string_view.h @@ -446,8 +446,6 @@ class basic_string_view { using string_view = basic_string_view; using wstring_view = basic_string_view; - - // DEPRECATED name equivalence OIIO_DEPRECATED("Use string_view (2.3)") typedef string_view string_ref; diff --git a/src/include/OpenImageIO/strutil.h b/src/include/OpenImageIO/strutil.h index ba23c056d8..d120b817d1 100644 --- a/src/include/OpenImageIO/strutil.h +++ b/src/include/OpenImageIO/strutil.h @@ -670,13 +670,15 @@ template<> inline double from_string (string_view s) { template<> inline int64_t from_string(string_view s) { // For conversion of string_view to unsigned int, fall back on strtoll. - auto r = strtoll(std::string(s).c_str(), nullptr, 10); + std::string s2 = std::string(s); + auto r = strtoll(s2.c_str(), nullptr, 10); return static_cast(r); } template<> inline uint64_t from_string(string_view s) { // For conversion of string_view to unsigned int, fall back on strtoull. - auto r = strtoull(std::string(s).c_str(), nullptr, 10); + std::string s2 = std::string(s); + auto r = strtoull(s2.c_str(), nullptr, 10); return static_cast(r); } #endif diff --git a/src/libOpenImageIO/imagebuf.cpp b/src/libOpenImageIO/imagebuf.cpp index b71b817832..550e5d7254 100644 --- a/src/libOpenImageIO/imagebuf.cpp +++ b/src/libOpenImageIO/imagebuf.cpp @@ -677,7 +677,7 @@ ImageBufImpl::error(string_view message) const // a single newline. if (m_err.size() && m_err.back() != '\n') m_err += '\n'; - m_err += message; + m_err += std::string(message); } diff --git a/src/libOpenImageIO/imageinput.cpp b/src/libOpenImageIO/imageinput.cpp index fe53500ab7..6d16f7978b 100644 --- a/src/libOpenImageIO/imageinput.cpp +++ b/src/libOpenImageIO/imageinput.cpp @@ -1072,7 +1072,7 @@ ImageInput::append_error(string_view message) const if (errptr->size() < 1024 * 1024 * 16) { if (errptr->size() && errptr->back() != '\n') *errptr += '\n'; - *errptr += message; + *errptr += std::string(message); } } diff --git a/src/libOpenImageIO/imageio.cpp b/src/libOpenImageIO/imageio.cpp index 97c3408c66..a03ab107bd 100644 --- a/src/libOpenImageIO/imageio.cpp +++ b/src/libOpenImageIO/imageio.cpp @@ -233,12 +233,12 @@ pvt::append_error(string_view message) // a single newline. if (error_msg.size() && error_msg.back() != '\n') error_msg += '\n'; - error_msg += message; + error_msg += std::string(message); // Remove a single trailing newline if (message.size() && message.back() == '\n') message.remove_suffix(1); - error_msg = message; + error_msg = std::string(message); } diff --git a/src/libOpenImageIO/imageoutput.cpp b/src/libOpenImageIO/imageoutput.cpp index 378302bfbd..4a1320df97 100644 --- a/src/libOpenImageIO/imageoutput.cpp +++ b/src/libOpenImageIO/imageoutput.cpp @@ -271,7 +271,7 @@ ImageOutput::append_error(string_view message) const && "Accumulated error messages > 16MB. Try checking return codes!"); if (errptr->size() && errptr->back() != '\n') *errptr += '\n'; - *errptr += message; + *errptr += std::string(message); } diff --git a/src/libtexture/imagecache.cpp b/src/libtexture/imagecache.cpp index 6d42e1e6ad..0635b9545a 100644 --- a/src/libtexture/imagecache.cpp +++ b/src/libtexture/imagecache.cpp @@ -3942,7 +3942,7 @@ ImageCacheImpl::append_error(string_view message) const && "Accumulated error messages > 16MB. Try checking return codes!"); if (errptr->size() && errptr->back() != '\n') *errptr += '\n'; - *errptr += message; + *errptr += std::string(message); } diff --git a/src/libtexture/texturesys.cpp b/src/libtexture/texturesys.cpp index 7c604791ef..619146d155 100644 --- a/src/libtexture/texturesys.cpp +++ b/src/libtexture/texturesys.cpp @@ -927,7 +927,7 @@ TextureSystemImpl::append_error(string_view message) const && "Accumulated error messages > 16MB. Try checking return codes!"); if (errptr->size() && errptr->back() != '\n') *errptr += '\n'; - *errptr += message; + *errptr += std::string(message); } diff --git a/src/libutil/filesystem.cpp b/src/libutil/filesystem.cpp index b59de52e8a..786766dfbc 100644 --- a/src/libutil/filesystem.cpp +++ b/src/libutil/filesystem.cpp @@ -35,6 +35,9 @@ # include # include # include +#ifdef __APPLE__ +# include +#endif #endif #if defined(USE_STD_FILESYSTEM) @@ -778,12 +781,19 @@ Filesystem::last_write_time(string_view path, std::time_t time) noexcept times.modtime = time; _wutime(u8path(path).c_str(), ×); #else +#ifndef __APPLE__ struct timespec times[2]; times[0].tv_sec = 0; times[0].tv_nsec = UTIME_OMIT; times[1].tv_sec = time; times[1].tv_nsec = 0; - utimensat((int)AT_FDCWD, u8path(path).c_str(), times, AT_SYMLINK_NOFOLLOW); +utimensat((int)AT_FDCWD, u8path(path).c_str(), times, AT_SYMLINK_NOFOLLOW); +#else + struct utimbuf times; + times.actime = time; + times.modtime = time; + utime(u8path(path).c_str(), ×); +#endif #endif } diff --git a/src/oiiotool/imagerec.cpp b/src/oiiotool/imagerec.cpp index 9975c83e26..eef31b75e4 100644 --- a/src/oiiotool/imagerec.cpp +++ b/src/oiiotool/imagerec.cpp @@ -413,5 +413,5 @@ ImageRec::append_error(string_view message) const && "Accumulated error messages > 16MB. Try checking return codes!"); if (m_err.size() && m_err[m_err.size() - 1] != '\n') m_err += '\n'; - m_err += message; + m_err += std::string(message); } From 1cb9f614d2927a77a68da419e953dd41134d4d5a Mon Sep 17 00:00:00 2001 From: Tuomas Tonteri Date: Fri, 31 Mar 2023 01:12:24 +0300 Subject: [PATCH 2/3] Revert "Make project compile with clang 11.0.1-2 in Mac" This reverts commit 169aa33d5e8fe440fbbb12fe7201a52c052ebb51. --- src/include/OpenImageIO/string_view.h | 2 ++ src/include/OpenImageIO/strutil.h | 6 ++---- src/libOpenImageIO/imagebuf.cpp | 2 +- src/libOpenImageIO/imageinput.cpp | 2 +- src/libOpenImageIO/imageio.cpp | 4 ++-- src/libOpenImageIO/imageoutput.cpp | 2 +- src/libtexture/imagecache.cpp | 2 +- src/libtexture/texturesys.cpp | 2 +- src/libutil/filesystem.cpp | 12 +----------- src/oiiotool/imagerec.cpp | 2 +- 10 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/include/OpenImageIO/string_view.h b/src/include/OpenImageIO/string_view.h index 60d3c5487e..b0df6b8f53 100644 --- a/src/include/OpenImageIO/string_view.h +++ b/src/include/OpenImageIO/string_view.h @@ -446,6 +446,8 @@ class basic_string_view { using string_view = basic_string_view; using wstring_view = basic_string_view; + + // DEPRECATED name equivalence OIIO_DEPRECATED("Use string_view (2.3)") typedef string_view string_ref; diff --git a/src/include/OpenImageIO/strutil.h b/src/include/OpenImageIO/strutil.h index d120b817d1..ba23c056d8 100644 --- a/src/include/OpenImageIO/strutil.h +++ b/src/include/OpenImageIO/strutil.h @@ -670,15 +670,13 @@ template<> inline double from_string (string_view s) { template<> inline int64_t from_string(string_view s) { // For conversion of string_view to unsigned int, fall back on strtoll. - std::string s2 = std::string(s); - auto r = strtoll(s2.c_str(), nullptr, 10); + auto r = strtoll(std::string(s).c_str(), nullptr, 10); return static_cast(r); } template<> inline uint64_t from_string(string_view s) { // For conversion of string_view to unsigned int, fall back on strtoull. - std::string s2 = std::string(s); - auto r = strtoull(s2.c_str(), nullptr, 10); + auto r = strtoull(std::string(s).c_str(), nullptr, 10); return static_cast(r); } #endif diff --git a/src/libOpenImageIO/imagebuf.cpp b/src/libOpenImageIO/imagebuf.cpp index 550e5d7254..b71b817832 100644 --- a/src/libOpenImageIO/imagebuf.cpp +++ b/src/libOpenImageIO/imagebuf.cpp @@ -677,7 +677,7 @@ ImageBufImpl::error(string_view message) const // a single newline. if (m_err.size() && m_err.back() != '\n') m_err += '\n'; - m_err += std::string(message); + m_err += message; } diff --git a/src/libOpenImageIO/imageinput.cpp b/src/libOpenImageIO/imageinput.cpp index 6d16f7978b..fe53500ab7 100644 --- a/src/libOpenImageIO/imageinput.cpp +++ b/src/libOpenImageIO/imageinput.cpp @@ -1072,7 +1072,7 @@ ImageInput::append_error(string_view message) const if (errptr->size() < 1024 * 1024 * 16) { if (errptr->size() && errptr->back() != '\n') *errptr += '\n'; - *errptr += std::string(message); + *errptr += message; } } diff --git a/src/libOpenImageIO/imageio.cpp b/src/libOpenImageIO/imageio.cpp index a03ab107bd..97c3408c66 100644 --- a/src/libOpenImageIO/imageio.cpp +++ b/src/libOpenImageIO/imageio.cpp @@ -233,12 +233,12 @@ pvt::append_error(string_view message) // a single newline. if (error_msg.size() && error_msg.back() != '\n') error_msg += '\n'; - error_msg += std::string(message); + error_msg += message; // Remove a single trailing newline if (message.size() && message.back() == '\n') message.remove_suffix(1); - error_msg = std::string(message); + error_msg = message; } diff --git a/src/libOpenImageIO/imageoutput.cpp b/src/libOpenImageIO/imageoutput.cpp index 4a1320df97..378302bfbd 100644 --- a/src/libOpenImageIO/imageoutput.cpp +++ b/src/libOpenImageIO/imageoutput.cpp @@ -271,7 +271,7 @@ ImageOutput::append_error(string_view message) const && "Accumulated error messages > 16MB. Try checking return codes!"); if (errptr->size() && errptr->back() != '\n') *errptr += '\n'; - *errptr += std::string(message); + *errptr += message; } diff --git a/src/libtexture/imagecache.cpp b/src/libtexture/imagecache.cpp index 0635b9545a..6d42e1e6ad 100644 --- a/src/libtexture/imagecache.cpp +++ b/src/libtexture/imagecache.cpp @@ -3942,7 +3942,7 @@ ImageCacheImpl::append_error(string_view message) const && "Accumulated error messages > 16MB. Try checking return codes!"); if (errptr->size() && errptr->back() != '\n') *errptr += '\n'; - *errptr += std::string(message); + *errptr += message; } diff --git a/src/libtexture/texturesys.cpp b/src/libtexture/texturesys.cpp index 619146d155..7c604791ef 100644 --- a/src/libtexture/texturesys.cpp +++ b/src/libtexture/texturesys.cpp @@ -927,7 +927,7 @@ TextureSystemImpl::append_error(string_view message) const && "Accumulated error messages > 16MB. Try checking return codes!"); if (errptr->size() && errptr->back() != '\n') *errptr += '\n'; - *errptr += std::string(message); + *errptr += message; } diff --git a/src/libutil/filesystem.cpp b/src/libutil/filesystem.cpp index 786766dfbc..b59de52e8a 100644 --- a/src/libutil/filesystem.cpp +++ b/src/libutil/filesystem.cpp @@ -35,9 +35,6 @@ # include # include # include -#ifdef __APPLE__ -# include -#endif #endif #if defined(USE_STD_FILESYSTEM) @@ -781,19 +778,12 @@ Filesystem::last_write_time(string_view path, std::time_t time) noexcept times.modtime = time; _wutime(u8path(path).c_str(), ×); #else -#ifndef __APPLE__ struct timespec times[2]; times[0].tv_sec = 0; times[0].tv_nsec = UTIME_OMIT; times[1].tv_sec = time; times[1].tv_nsec = 0; -utimensat((int)AT_FDCWD, u8path(path).c_str(), times, AT_SYMLINK_NOFOLLOW); -#else - struct utimbuf times; - times.actime = time; - times.modtime = time; - utime(u8path(path).c_str(), ×); -#endif + utimensat((int)AT_FDCWD, u8path(path).c_str(), times, AT_SYMLINK_NOFOLLOW); #endif } diff --git a/src/oiiotool/imagerec.cpp b/src/oiiotool/imagerec.cpp index eef31b75e4..9975c83e26 100644 --- a/src/oiiotool/imagerec.cpp +++ b/src/oiiotool/imagerec.cpp @@ -413,5 +413,5 @@ ImageRec::append_error(string_view message) const && "Accumulated error messages > 16MB. Try checking return codes!"); if (m_err.size() && m_err[m_err.size() - 1] != '\n') m_err += '\n'; - m_err += std::string(message); + m_err += message; } From 2ec6cbb17a7dc7685a778499851104be9522dad6 Mon Sep 17 00:00:00 2001 From: Tuomas Tonteri Date: Fri, 31 Mar 2023 01:13:21 +0300 Subject: [PATCH 3/3] Make project compile with clang 11.0.1-2 in Mac (2) --- src/libOpenImageIO/imagebuf.cpp | 2 +- src/libOpenImageIO/imageinput.cpp | 2 +- src/libOpenImageIO/imageio.cpp | 4 ++-- src/libOpenImageIO/imageoutput.cpp | 2 +- src/libtexture/imagecache.cpp | 2 +- src/libtexture/texturesys.cpp | 2 +- src/libutil/filesystem.cpp | 11 +++++------ src/oiiotool/imagerec.cpp | 2 +- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/libOpenImageIO/imagebuf.cpp b/src/libOpenImageIO/imagebuf.cpp index b71b817832..550e5d7254 100644 --- a/src/libOpenImageIO/imagebuf.cpp +++ b/src/libOpenImageIO/imagebuf.cpp @@ -677,7 +677,7 @@ ImageBufImpl::error(string_view message) const // a single newline. if (m_err.size() && m_err.back() != '\n') m_err += '\n'; - m_err += message; + m_err += std::string(message); } diff --git a/src/libOpenImageIO/imageinput.cpp b/src/libOpenImageIO/imageinput.cpp index fe53500ab7..6d16f7978b 100644 --- a/src/libOpenImageIO/imageinput.cpp +++ b/src/libOpenImageIO/imageinput.cpp @@ -1072,7 +1072,7 @@ ImageInput::append_error(string_view message) const if (errptr->size() < 1024 * 1024 * 16) { if (errptr->size() && errptr->back() != '\n') *errptr += '\n'; - *errptr += message; + *errptr += std::string(message); } } diff --git a/src/libOpenImageIO/imageio.cpp b/src/libOpenImageIO/imageio.cpp index 97c3408c66..a03ab107bd 100644 --- a/src/libOpenImageIO/imageio.cpp +++ b/src/libOpenImageIO/imageio.cpp @@ -233,12 +233,12 @@ pvt::append_error(string_view message) // a single newline. if (error_msg.size() && error_msg.back() != '\n') error_msg += '\n'; - error_msg += message; + error_msg += std::string(message); // Remove a single trailing newline if (message.size() && message.back() == '\n') message.remove_suffix(1); - error_msg = message; + error_msg = std::string(message); } diff --git a/src/libOpenImageIO/imageoutput.cpp b/src/libOpenImageIO/imageoutput.cpp index 378302bfbd..4a1320df97 100644 --- a/src/libOpenImageIO/imageoutput.cpp +++ b/src/libOpenImageIO/imageoutput.cpp @@ -271,7 +271,7 @@ ImageOutput::append_error(string_view message) const && "Accumulated error messages > 16MB. Try checking return codes!"); if (errptr->size() && errptr->back() != '\n') *errptr += '\n'; - *errptr += message; + *errptr += std::string(message); } diff --git a/src/libtexture/imagecache.cpp b/src/libtexture/imagecache.cpp index 6d42e1e6ad..0635b9545a 100644 --- a/src/libtexture/imagecache.cpp +++ b/src/libtexture/imagecache.cpp @@ -3942,7 +3942,7 @@ ImageCacheImpl::append_error(string_view message) const && "Accumulated error messages > 16MB. Try checking return codes!"); if (errptr->size() && errptr->back() != '\n') *errptr += '\n'; - *errptr += message; + *errptr += std::string(message); } diff --git a/src/libtexture/texturesys.cpp b/src/libtexture/texturesys.cpp index 7c604791ef..619146d155 100644 --- a/src/libtexture/texturesys.cpp +++ b/src/libtexture/texturesys.cpp @@ -927,7 +927,7 @@ TextureSystemImpl::append_error(string_view message) const && "Accumulated error messages > 16MB. Try checking return codes!"); if (errptr->size() && errptr->back() != '\n') *errptr += '\n'; - *errptr += message; + *errptr += std::string(message); } diff --git a/src/libutil/filesystem.cpp b/src/libutil/filesystem.cpp index b59de52e8a..fa3ac7dd10 100644 --- a/src/libutil/filesystem.cpp +++ b/src/libutil/filesystem.cpp @@ -35,6 +35,7 @@ # include # include # include +# include #endif #if defined(USE_STD_FILESYSTEM) @@ -778,12 +779,10 @@ Filesystem::last_write_time(string_view path, std::time_t time) noexcept times.modtime = time; _wutime(u8path(path).c_str(), ×); #else - struct timespec times[2]; - times[0].tv_sec = 0; - times[0].tv_nsec = UTIME_OMIT; - times[1].tv_sec = time; - times[1].tv_nsec = 0; - utimensat((int)AT_FDCWD, u8path(path).c_str(), times, AT_SYMLINK_NOFOLLOW); + struct utimbuf times; + times.actime = time; + times.modtime = time; + utime(u8path(path).c_str(), ×); #endif } diff --git a/src/oiiotool/imagerec.cpp b/src/oiiotool/imagerec.cpp index 9975c83e26..eef31b75e4 100644 --- a/src/oiiotool/imagerec.cpp +++ b/src/oiiotool/imagerec.cpp @@ -413,5 +413,5 @@ ImageRec::append_error(string_view message) const && "Accumulated error messages > 16MB. Try checking return codes!"); if (m_err.size() && m_err[m_err.size() - 1] != '\n') m_err += '\n'; - m_err += message; + m_err += std::string(message); }