From 700d8e6614cf3b75e686fb5e491384efb675096c Mon Sep 17 00:00:00 2001 From: awr1 <41453959+awr1@users.noreply.github.com> Date: Tue, 14 Jul 2020 21:19:07 -0500 Subject: [PATCH 1/8] Fix MinGW builds (issues related to pragmas and format strings) --- code/AssetLib/Assbin/AssbinFileWriter.cpp | 8 ++++---- code/AssetLib/Assjson/cencode.h | 4 ++-- code/AssetLib/glTF/glTFAsset.inl | 12 ++++++------ code/AssetLib/glTF/glTFAssetWriter.inl | 6 +++--- code/AssetLib/glTF/glTFCommon.h | 8 ++++---- code/AssetLib/glTF/glTFExporter.cpp | 10 +++++++++- code/AssetLib/glTF2/glTF2Asset.inl | 14 +++++++------- contrib/poly2tri/poly2tri/sweep/sweep.cc | 8 ++++---- contrib/zip/src/zip.h | 8 ++++++-- include/assimp/StringUtils.h | 12 ++++++++++-- 10 files changed, 55 insertions(+), 35 deletions(-) diff --git a/code/AssetLib/Assbin/AssbinFileWriter.cpp b/code/AssetLib/Assbin/AssbinFileWriter.cpp index a879e637c..83a647a0b 100644 --- a/code/AssetLib/Assbin/AssbinFileWriter.cpp +++ b/code/AssetLib/Assbin/AssbinFileWriter.cpp @@ -60,10 +60,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#ifdef _WIN32 +#if _MSC_VER #pragma warning(push) #pragma warning(disable : 4706) -#endif // _WIN32 +#endif // _MSC_VER namespace Assimp { @@ -825,8 +825,8 @@ void DumpSceneToAssbin( AssbinFileWriter fileWriter(shortened, compressed); fileWriter.WriteBinaryDump(pFile, cmd, pIOSystem, pScene); } -#ifdef _WIN32 +#if _MSC_VER #pragma warning(pop) -#endif // _WIN32 +#endif // _MSC_VER } // end of namespace Assimp diff --git a/code/AssetLib/Assjson/cencode.h b/code/AssetLib/Assjson/cencode.h index 6bf76724e..a7893c434 100644 --- a/code/AssetLib/Assjson/cencode.h +++ b/code/AssetLib/Assjson/cencode.h @@ -8,9 +8,9 @@ For details, see http://sourceforge.net/projects/libb64 #ifndef BASE64_CENCODE_H #define BASE64_CENCODE_H -#ifdef _WIN32 +#ifdef _MSC_VER #pragma warning(disable : 4127 ) -#endif // _WIN32 +#endif // _MSC_VER typedef enum { diff --git a/code/AssetLib/glTF/glTFAsset.inl b/code/AssetLib/glTF/glTFAsset.inl index 116f76535..eae56a64d 100644 --- a/code/AssetLib/glTF/glTFAsset.inl +++ b/code/AssetLib/glTF/glTFAsset.inl @@ -57,10 +57,10 @@ namespace glTF { namespace { -#ifdef _WIN32 +#if _MSC_VER # pragma warning(push) # pragma warning(disable : 4706) -#endif // _WIN32 +#endif // _MSC_VER // // JSON Value reading helpers @@ -372,7 +372,7 @@ inline void Buffer::EncodedRegion_Mark(const size_t pOffset, const size_t pEncod char val[val_size]; - ai_snprintf(val, val_size, "%llu", (long long)pOffset); + ai_snprintf(val, val_size, AI_SIZEFMT, pOffset); throw DeadlyImportError(std::string("GLTF: incorrect offset value (") + val + ") for marking encoded region."); } @@ -382,7 +382,7 @@ inline void Buffer::EncodedRegion_Mark(const size_t pOffset, const size_t pEncod char val[val_size]; - ai_snprintf(val, val_size, "%llu, %llu", (long long)pOffset, (long long)pEncodedData_Length); + ai_snprintf(val, val_size, AI_SIZEFMT, AI_SIZEFMT, pOffset, pEncodedData_Length); throw DeadlyImportError(std::string("GLTF: encoded region with offset/length (") + val + ") is out of range."); } @@ -1412,8 +1412,8 @@ inline std::string Asset::FindUniqueID(const std::string &str, const char *suffi return id; } -#ifdef _WIN32 +#if _MSC_VER # pragma warning(pop) -#endif // WIN32 +#endif // _MSC_VER } // namespace glTF diff --git a/code/AssetLib/glTF/glTFAssetWriter.inl b/code/AssetLib/glTF/glTFAssetWriter.inl index d8d2556fa..779c8ce58 100644 --- a/code/AssetLib/glTF/glTFAssetWriter.inl +++ b/code/AssetLib/glTF/glTFAssetWriter.inl @@ -43,10 +43,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _WIN32 +#if _MSC_VER # pragma warning(push) # pragma warning( disable : 4706) -#endif // _WIN32 +#endif // _MSC_VER namespace glTF { @@ -707,7 +707,7 @@ namespace glTF { w.WriteObjects(d); } -#ifdef _WIN32 +#if _MSC_VER # pragma warning(pop) #endif // _WIN32 diff --git a/code/AssetLib/glTF/glTFCommon.h b/code/AssetLib/glTF/glTFCommon.h index b151918b6..f70780ed4 100644 --- a/code/AssetLib/glTF/glTFCommon.h +++ b/code/AssetLib/glTF/glTFCommon.h @@ -190,10 +190,10 @@ inline void CopyValue(const glTFCommon::mat4 &v, aiMatrix4x4 &o) { o.d4 = v[15]; } -#ifdef _WIN32 +#if _MSC_VER # pragma warning(push) # pragma warning(disable : 4310) -#endif // _WIN32 +#endif // _MSC_VER inline std::string getCurrentAssetDir(const std::string &pFile) { std::string path = pFile; @@ -204,9 +204,9 @@ inline std::string getCurrentAssetDir(const std::string &pFile) { return path; } -#ifdef _WIN32 +#if _MSC_VER # pragma warning(pop) -#endif // _WIN32 +#endif // _MSC_VER namespace Util { diff --git a/code/AssetLib/glTF/glTFExporter.cpp b/code/AssetLib/glTF/glTFExporter.cpp index b85affc08..3edb87623 100644 --- a/code/AssetLib/glTF/glTFExporter.cpp +++ b/code/AssetLib/glTF/glTFExporter.cpp @@ -525,6 +525,10 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, Ref encoder; o3dgc::IndexedFaceSet comp_o3dgc_ifs; @@ -793,6 +797,10 @@ void glTFExporter::ExportMeshes() } } +#if __GNUC__ +#pragma GCC diagnostic pop +#endif // __GNUC__ + /* * Export the root node of the node hierarchy. * Calls ExportNode for all children. diff --git a/code/AssetLib/glTF2/glTF2Asset.inl b/code/AssetLib/glTF2/glTF2Asset.inl index 142f39841..ca622d1e2 100644 --- a/code/AssetLib/glTF2/glTF2Asset.inl +++ b/code/AssetLib/glTF2/glTF2Asset.inl @@ -436,7 +436,7 @@ inline void Buffer::EncodedRegion_Mark(const size_t pOffset, const size_t pEncod char val[val_size]; - ai_snprintf(val, val_size, "%llu", (long long)pOffset); + ai_snprintf(val, val_size, AI_SIZEFMT, pOffset); throw DeadlyImportError(std::string("GLTF: incorrect offset value (") + val + ") for marking encoded region."); } @@ -446,7 +446,7 @@ inline void Buffer::EncodedRegion_Mark(const size_t pOffset, const size_t pEncod char val[val_size]; - ai_snprintf(val, val_size, "%llu, %llu", (long long)pOffset, (long long)pEncodedData_Length); + ai_snprintf(val, val_size, AI_SIZEFMT, AI_SIZEFMT, pOffset, pEncodedData_Length); throw DeadlyImportError(std::string("GLTF: encoded region with offset/length (") + val + ") is out of range."); } @@ -1042,10 +1042,10 @@ inline int Compare(const char *attr, const char (&str)[N]) { return (strncmp(attr, str, N - 1) == 0) ? N - 1 : 0; } -#ifdef _WIN32 +#if _MSC_VER #pragma warning(push) #pragma warning(disable : 4706) -#endif // _WIN32 +#endif // _MSC_VER inline bool GetAttribVector(Mesh::Primitive &p, const char *attr, Mesh::AccessorList *&v, int &pos) { if ((pos = Compare(attr, "POSITION"))) { @@ -1723,8 +1723,8 @@ inline std::string Asset::FindUniqueID(const std::string &str, const char *suffi return id; } -#ifdef _WIN32 -#pragma warning(pop) -#endif // _WIN32 +#if _MSC_VER +# pragma warning(pop) +#endif // _MSC_VER } // namespace glTF2 diff --git a/contrib/poly2tri/poly2tri/sweep/sweep.cc b/contrib/poly2tri/poly2tri/sweep/sweep.cc index 9e3666001..23aeb6b57 100644 --- a/contrib/poly2tri/poly2tri/sweep/sweep.cc +++ b/contrib/poly2tri/poly2tri/sweep/sweep.cc @@ -36,10 +36,10 @@ namespace p2t { -#ifdef _WIN32 +#ifdef _MSC_VER # pragma warning(push) # pragma warning( disable : 4702 ) -#endif // _WIN32 +#endif // _MSC_VER // Triangulate simple polygon with holes void Sweep::Triangulate(SweepContext& tcx) @@ -800,8 +800,8 @@ Sweep::~Sweep() { } -#ifdef _WIN32 +#ifdef _MSC_VER # pragma warning( pop ) -#endif // _WIN32 +#endif // _MSC_VER } diff --git a/contrib/zip/src/zip.h b/contrib/zip/src/zip.h index 807e328a8..2ebe9394d 100644 --- a/contrib/zip/src/zip.h +++ b/contrib/zip/src/zip.h @@ -15,9 +15,9 @@ #include #include -#ifdef _WIN32 +#ifdef _MSC_VER #pragma warning(disable : 4127 ) -#endif //_WIN32 +#endif //_MSC_VER #ifdef __cplusplus extern "C" { @@ -319,6 +319,10 @@ extern int zip_extract(const char *zipname, const char *dir, /** @} */ +#ifdef _MSC_VER +#pragma warning(pop) +#endif //_MSC_VER + #ifdef __cplusplus } #endif diff --git a/include/assimp/StringUtils.h b/include/assimp/StringUtils.h index 7e1cb4ce0..d848a6527 100644 --- a/include/assimp/StringUtils.h +++ b/include/assimp/StringUtils.h @@ -53,6 +53,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#ifdef _MSC_VER +# define AI_SIZEFMT "%Iu" +#else +# define AI_SIZEFMT "%zu" +#endif + /// @fn ai_snprintf /// @brief The portable version of the function snprintf ( C99 standard ), which works on visual studio compilers 2013 and earlier. /// @param outBuf The buffer to write in @@ -87,6 +93,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. return count; } +#elif defined(__MINGW32__) +# define ai_snprintf __mingw_snprintf #else # define ai_snprintf snprintf #endif @@ -150,7 +158,7 @@ std::string DecimalToHexa( T toConvert ) { /// @param g aiColor.g /// @param b aiColor.b /// @param a aiColor.a -/// @param with_head # +/// @param with_head # /// @return The hexadecimal string, is empty in case of an error. AI_FORCE_INLINE std::string Rgba2Hex(int r, int g, int b, int a, bool with_head) { std::stringstream ss; @@ -158,7 +166,7 @@ AI_FORCE_INLINE std::string Rgba2Hex(int r, int g, int b, int a, bool with_head) ss << "#"; } ss << std::hex << (r << 24 | g << 16 | b << 8 | a); - + return ss.str(); } From 93d567e3b10285d7fde4ec77edd5d5b71ddf26d4 Mon Sep 17 00:00:00 2001 From: awr1 <41453959+awr1@users.noreply.github.com> Date: Tue, 14 Jul 2020 21:32:22 -0500 Subject: [PATCH 2/8] Fix sprintf format string --- code/AssetLib/glTF/glTFAsset.inl | 2 +- code/AssetLib/glTF2/glTF2Asset.inl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/glTF/glTFAsset.inl b/code/AssetLib/glTF/glTFAsset.inl index eae56a64d..ea6a6b11a 100644 --- a/code/AssetLib/glTF/glTFAsset.inl +++ b/code/AssetLib/glTF/glTFAsset.inl @@ -382,7 +382,7 @@ inline void Buffer::EncodedRegion_Mark(const size_t pOffset, const size_t pEncod char val[val_size]; - ai_snprintf(val, val_size, AI_SIZEFMT, AI_SIZEFMT, pOffset, pEncodedData_Length); + ai_snprintf(val, val_size, AI_SIZEFMT " " AI_SIZEFMT, pOffset, pEncodedData_Length); throw DeadlyImportError(std::string("GLTF: encoded region with offset/length (") + val + ") is out of range."); } diff --git a/code/AssetLib/glTF2/glTF2Asset.inl b/code/AssetLib/glTF2/glTF2Asset.inl index ca622d1e2..a89b65f1a 100644 --- a/code/AssetLib/glTF2/glTF2Asset.inl +++ b/code/AssetLib/glTF2/glTF2Asset.inl @@ -446,7 +446,7 @@ inline void Buffer::EncodedRegion_Mark(const size_t pOffset, const size_t pEncod char val[val_size]; - ai_snprintf(val, val_size, AI_SIZEFMT, AI_SIZEFMT, pOffset, pEncodedData_Length); + ai_snprintf(val, val_size, AI_SIZEFMT " " AI_SIZEFMT, pOffset, pEncodedData_Length); throw DeadlyImportError(std::string("GLTF: encoded region with offset/length (") + val + ") is out of range."); } From 3bf6963d206ad2ab120eb4ea56b57e1f7f23d120 Mon Sep 17 00:00:00 2001 From: awr1 <41453959+awr1@users.noreply.github.com> Date: Tue, 14 Jul 2020 21:34:30 -0500 Subject: [PATCH 3/8] Use a better divider for import error --- code/AssetLib/glTF/glTFAsset.inl | 2 +- code/AssetLib/glTF2/glTF2Asset.inl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/glTF/glTFAsset.inl b/code/AssetLib/glTF/glTFAsset.inl index ea6a6b11a..a5e539345 100644 --- a/code/AssetLib/glTF/glTFAsset.inl +++ b/code/AssetLib/glTF/glTFAsset.inl @@ -382,7 +382,7 @@ inline void Buffer::EncodedRegion_Mark(const size_t pOffset, const size_t pEncod char val[val_size]; - ai_snprintf(val, val_size, AI_SIZEFMT " " AI_SIZEFMT, pOffset, pEncodedData_Length); + ai_snprintf(val, val_size, AI_SIZEFMT "/" AI_SIZEFMT, pOffset, pEncodedData_Length); throw DeadlyImportError(std::string("GLTF: encoded region with offset/length (") + val + ") is out of range."); } diff --git a/code/AssetLib/glTF2/glTF2Asset.inl b/code/AssetLib/glTF2/glTF2Asset.inl index a89b65f1a..2dfe2f41e 100644 --- a/code/AssetLib/glTF2/glTF2Asset.inl +++ b/code/AssetLib/glTF2/glTF2Asset.inl @@ -446,7 +446,7 @@ inline void Buffer::EncodedRegion_Mark(const size_t pOffset, const size_t pEncod char val[val_size]; - ai_snprintf(val, val_size, AI_SIZEFMT " " AI_SIZEFMT, pOffset, pEncodedData_Length); + ai_snprintf(val, val_size, AI_SIZEFMT "/" AI_SIZEFMT, pOffset, pEncodedData_Length); throw DeadlyImportError(std::string("GLTF: encoded region with offset/length (") + val + ") is out of range."); } From b3f61f87597d38e4c611edcc80c326ae726bbdb3 Mon Sep 17 00:00:00 2001 From: awr1 <41453959+awr1@users.noreply.github.com> Date: Tue, 14 Jul 2020 21:44:33 -0500 Subject: [PATCH 4/8] Fix error where -Wunused-but-set-variable might not be available --- code/AssetLib/glTF/glTFExporter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/glTF/glTFExporter.cpp b/code/AssetLib/glTF/glTFExporter.cpp index 3edb87623..5f911b422 100644 --- a/code/AssetLib/glTF/glTFExporter.cpp +++ b/code/AssetLib/glTF/glTFExporter.cpp @@ -525,9 +525,9 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, Ref Date: Tue, 14 Jul 2020 21:48:46 -0500 Subject: [PATCH 5/8] Remove unnecessary inversion in preproc --- code/AssetLib/glTF/glTFExporter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/glTF/glTFExporter.cpp b/code/AssetLib/glTF/glTFExporter.cpp index 5f911b422..44a37af49 100644 --- a/code/AssetLib/glTF/glTFExporter.cpp +++ b/code/AssetLib/glTF/glTFExporter.cpp @@ -525,7 +525,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, Ref Date: Tue, 14 Jul 2020 21:50:22 -0500 Subject: [PATCH 6/8] Preproc conditional should be &&, not || --- code/AssetLib/glTF/glTFExporter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/glTF/glTFExporter.cpp b/code/AssetLib/glTF/glTFExporter.cpp index 44a37af49..032555fc3 100644 --- a/code/AssetLib/glTF/glTFExporter.cpp +++ b/code/AssetLib/glTF/glTFExporter.cpp @@ -525,7 +525,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, Ref Date: Tue, 14 Jul 2020 21:58:36 -0500 Subject: [PATCH 7/8] Try to fix lexing issue with preproc w/r/t __has_warning --- code/AssetLib/glTF/glTFExporter.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/glTF/glTFExporter.cpp b/code/AssetLib/glTF/glTFExporter.cpp index 032555fc3..be9dddef7 100644 --- a/code/AssetLib/glTF/glTFExporter.cpp +++ b/code/AssetLib/glTF/glTFExporter.cpp @@ -525,9 +525,11 @@ void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref& meshRef, Ref Date: Tue, 14 Jul 2020 22:07:24 -0500 Subject: [PATCH 8/8] Ensure that zip.h warning disable is pushed --- contrib/zip/src/zip.h | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/zip/src/zip.h b/contrib/zip/src/zip.h index 2ebe9394d..87f3654f4 100644 --- a/contrib/zip/src/zip.h +++ b/contrib/zip/src/zip.h @@ -16,6 +16,7 @@ #include #ifdef _MSC_VER +#pragma warning(push) #pragma warning(disable : 4127 ) #endif //_MSC_VER