From 8d8ba521e2094d0da89f7446f3027c899a5e6be4 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Wed, 2 Dec 2020 02:05:14 +0530 Subject: [PATCH 1/2] Check _MSC_VER for MSVC specific pragma directives. This fixes build issues when compiled with compiles like Clang or GCC. --- code/AssetLib/Assjson/cencode.c | 14 +++++++++----- contrib/Open3DGC/o3dgcSC3DMCDecoder.inl | 8 ++++---- contrib/Open3DGC/o3dgcSC3DMCEncoder.inl | 8 ++++---- contrib/Open3DGC/o3dgcTimer.h | 2 ++ contrib/zip/src/zip.c | 4 ++++ include/assimp/mesh.h | 12 ++++++------ .../SimpleTexturedDirectx11/TextureLoader.cpp | 6 ++++++ .../SimpleTexturedDirectx11/TextureLoader.h | 6 ++++++ .../SimpleTexturedDirectx11/main.cpp | 2 ++ .../SimpleTexturedOpenGL/src/model_loading.cpp | 6 ++++++ 10 files changed, 49 insertions(+), 19 deletions(-) diff --git a/code/AssetLib/Assjson/cencode.c b/code/AssetLib/Assjson/cencode.c index 0ed979b01..614a2671f 100644 --- a/code/AssetLib/Assjson/cencode.c +++ b/code/AssetLib/Assjson/cencode.c @@ -9,8 +9,10 @@ For details, see http://sourceforge.net/projects/libb64 const int CHARS_PER_LINE = 72; +#ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4244) +#endif // _MSC_VER void base64_init_encodestate(base64_encodestate* state_in) { @@ -33,9 +35,9 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, char* codechar = code_out; char result; char fragment; - + result = state_in->result; - + switch (state_in->step) { while (1) @@ -74,7 +76,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, *codechar++ = base64_encode_value(result); result = (fragment & 0x03f) >> 0; *codechar++ = base64_encode_value(result); - + ++(state_in->stepcount); if (state_in->stepcount == CHARS_PER_LINE/4) { @@ -90,7 +92,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, int base64_encode_blockend(char* code_out, base64_encodestate* state_in) { char* codechar = code_out; - + switch (state_in->step) { case step_B: @@ -106,8 +108,10 @@ int base64_encode_blockend(char* code_out, base64_encodestate* state_in) break; } *codechar++ = '\n'; - + return (int)(codechar - code_out); } +#ifdef _MSC_VER #pragma warning(pop) +#endif // _MSC_VER diff --git a/contrib/Open3DGC/o3dgcSC3DMCDecoder.inl b/contrib/Open3DGC/o3dgcSC3DMCDecoder.inl index c965fcd50..8bd85f27b 100644 --- a/contrib/Open3DGC/o3dgcSC3DMCDecoder.inl +++ b/contrib/Open3DGC/o3dgcSC3DMCDecoder.inl @@ -27,10 +27,10 @@ THE SOFTWARE. #include "o3dgcArithmeticCodec.h" #include "o3dgcTimer.h" -#ifdef _WIN32 +#ifdef _MSC_VER # pragma warning(push) # pragma warning( disable : 4456) -#endif // _WIN32 +#endif // _MSC_VER //#define DEBUG_VERBOSE @@ -852,9 +852,9 @@ namespace o3dgc } } // namespace o3dgc -#ifdef _WIN32 +#ifdef _MSC_VER # pragma warning( pop ) -#endif // _WIN32 +#endif // _MSC_VER #endif // O3DGC_SC3DMC_DECODER_INL diff --git a/contrib/Open3DGC/o3dgcSC3DMCEncoder.inl b/contrib/Open3DGC/o3dgcSC3DMCEncoder.inl index 78d4b3e78..ca1e0ea76 100644 --- a/contrib/Open3DGC/o3dgcSC3DMCEncoder.inl +++ b/contrib/Open3DGC/o3dgcSC3DMCEncoder.inl @@ -32,10 +32,10 @@ THE SOFTWARE. //#define DEBUG_VERBOSE -#ifdef _WIN32 +#ifdef _MSC_VER # pragma warning(push) # pragma warning(disable : 4456) -#endif // _WIN32 +#endif // _MSC_VER namespace o3dgc { @@ -927,9 +927,9 @@ namespace o3dgc } } // namespace o3dgc -#ifdef _WIN32 +#ifdef _MSC_VER # pragma warning(pop) -#endif // _WIN32 +#endif // _MSC_VER #endif // O3DGC_SC3DMC_ENCODER_INL diff --git a/contrib/Open3DGC/o3dgcTimer.h b/contrib/Open3DGC/o3dgcTimer.h index d9a285968..f5ed0c83f 100644 --- a/contrib/Open3DGC/o3dgcTimer.h +++ b/contrib/Open3DGC/o3dgcTimer.h @@ -28,7 +28,9 @@ THE SOFTWARE. #ifdef _WIN32 /* Thank you, Microsoft, for file WinDef.h with min/max redefinition. */ +#ifndef NOMINMAX #define NOMINMAX +#endif #include #elif __APPLE__ #include diff --git a/contrib/zip/src/zip.c b/contrib/zip/src/zip.c index 0020df0ed..83e8e2a41 100644 --- a/contrib/zip/src/zip.c +++ b/contrib/zip/src/zip.c @@ -18,8 +18,10 @@ /* Win32, DOS, MSVC, MSVS */ #include +#ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4706) +#endif // _MSC_VER #define MKDIR(DIRNAME) _mkdir(DIRNAME) #define STRCLONE(STR) ((STR) ? _strdup(STR) : NULL) @@ -968,4 +970,6 @@ out: return status; } +#ifdef _MSC_VER #pragma warning(pop) +#endif // _MSC_VER diff --git a/include/assimp/mesh.h b/include/assimp/mesh.h index 4b5af97ce..ec1062837 100644 --- a/include/assimp/mesh.h +++ b/include/assimp/mesh.h @@ -52,9 +52,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma GCC system_header #endif -#ifdef _WIN32 +#ifdef _MSC_VER #pragma warning(disable : 4351) -#endif // _WIN32 +#endif // _MSC_VER #include #include @@ -458,8 +458,8 @@ struct aiAnimMesh { */ unsigned int mNumVertices; - /** - * Weight of the AnimMesh. + /** + * Weight of the AnimMesh. */ float mWeight; @@ -713,8 +713,8 @@ struct aiMesh { * Note! Currently only works with Collada loader.*/ C_STRUCT aiAnimMesh **mAnimMeshes; - /** - * Method of morphing when animeshes are specified. + /** + * Method of morphing when animeshes are specified. */ unsigned int mMethod; diff --git a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/TextureLoader.cpp b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/TextureLoader.cpp index c3269d290..01ba343e8 100644 --- a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/TextureLoader.cpp +++ b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/TextureLoader.cpp @@ -31,10 +31,16 @@ #include #include +#ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4005) +#endif // _MSC_VER + #include + +#ifdef _MSC_VER #pragma warning(pop) +#endif // _MSC_VER #include diff --git a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/TextureLoader.h b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/TextureLoader.h index c2e0b5214..5448daf2a 100644 --- a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/TextureLoader.h +++ b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/TextureLoader.h @@ -31,10 +31,16 @@ #include +#ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4005) +#endif // _MSC_VER + #include + +#ifdef _MSC_VER #pragma warning(pop) +#endif // _MSC_VER HRESULT CreateWICTextureFromMemory(_In_ ID3D11Device* d3dDevice, _In_opt_ ID3D11DeviceContext* d3dContext, diff --git a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp index 5cce7c376..02e2b6088 100644 --- a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp +++ b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp @@ -25,10 +25,12 @@ #include "UTFConverter.h" #include "SafeRelease.hpp" +#ifdef _MSC_VER #pragma comment (lib, "d3d11.lib") #pragma comment (lib, "Dxgi.lib") #pragma comment(lib,"d3dcompiler.lib") #pragma comment (lib, "dxguid.lib") +#endif // _MSC_VER using namespace DirectX; using namespace AssimpSamples::SharedCode; diff --git a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp index 806da8f8a..a36c792d4 100644 --- a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp +++ b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp @@ -18,10 +18,16 @@ #include #include +#ifdef _MSC_VER #pragma warning(disable: 4100) // Disable warning 'unreferenced formal parameter' +#endif // _MSC_VER + #define STB_IMAGE_IMPLEMENTATION #include "contrib/stb_image/stb_image.h" + +#ifdef _MSC_VER #pragma warning(default: 4100) // Enable warning 'unreferenced formal parameter' +#endif // _MSC_VER #include From 1910bbbdd9c91ee69708b129db5861dd1ac50736 Mon Sep 17 00:00:00 2001 From: huiji12321 <15117966074@163.com> Date: Fri, 4 Dec 2020 16:47:43 +0800 Subject: [PATCH 2/2] Additional Compiler Options for mips64el --- CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 102783ba3..b739674af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,9 +249,15 @@ IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW) SET(CMAKE_POSITION_INDEPENDENT_CODE ON) ENDIF() # hide all not-exported symbols - SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall ${CMAKE_CXX_FLAGS}") - SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}") - SET(LIBSTDC++_LIBRARIES -lstdc++) + IF(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64" ) + SET(CMAKE_CXX_FLAGS "-mxgot -fvisibility=hidden -fno-strict-aliasing -Wall ${CMAKE_CXX_FLAGS}") + SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}") + SET(LIBSTDC++_LIBRARIES -lstdc++) + ELSE() + SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall ${CMAKE_CXX_FLAGS}") + SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}") + SET(LIBSTDC++_LIBRARIES -lstdc++) + ENDIF() ELSEIF(MSVC) # enable multi-core compilation with MSVC IF( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) # clang-cl