From 059a32654e660ac9dcfd9a31a8436fce6042c66f Mon Sep 17 00:00:00 2001 From: Jared Mulconry Date: Sun, 24 Sep 2017 19:29:43 +1000 Subject: [PATCH 1/7] Addressed warnings generated on MSVC across x86 and x64. --- code/MMDImporter.cpp | 2 +- code/glTF2Exporter.cpp | 2 +- samples/SimpleOpenGL/CMakeLists.txt | 5 +++++ samples/SimpleTexturedOpenGL/CMakeLists.txt | 5 +++++ tools/assimp_view/stdafx.h | 1 - 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/code/MMDImporter.cpp b/code/MMDImporter.cpp index 84797cba2..c40978c0e 100644 --- a/code/MMDImporter.cpp +++ b/code/MMDImporter.cpp @@ -118,7 +118,7 @@ void MMDImporter::InternReadFile(const std::string &file, aiScene *pScene, // Get the file-size and validate it, throwing an exception when fails fileStream.seekg(0, fileStream.end); - size_t fileSize = fileStream.tellg(); + size_t fileSize = static_cast(fileStream.tellg()); fileStream.seekg(0, fileStream.beg); if (fileSize < sizeof(pmx::PmxModel)) { diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index 12642a961..4ed8f20ff 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -741,7 +741,7 @@ void glTF2Exporter::MergeMeshes() for (unsigned int n = 0; n < mAsset->nodes.Size(); ++n) { Ref node = mAsset->nodes.Get(n); - unsigned int nMeshes = node->meshes.size(); + unsigned int nMeshes = static_cast(node->meshes.size()); //skip if it's 1 or less meshes per node if (nMeshes > 1) { diff --git a/samples/SimpleOpenGL/CMakeLists.txt b/samples/SimpleOpenGL/CMakeLists.txt index 52c994b63..455cbd8ca 100644 --- a/samples/SimpleOpenGL/CMakeLists.txt +++ b/samples/SimpleOpenGL/CMakeLists.txt @@ -16,6 +16,11 @@ IF ( NOT GLUT_FOUND ) ENDIF ( MSVC ) ENDIF ( NOT GLUT_FOUND ) +if ( MSVC ) + ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS ) + ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS ) +endif ( MSVC ) + INCLUDE_DIRECTORIES( ${Assimp_SOURCE_DIR}/include ${Assimp_SOURCE_DIR}/code diff --git a/samples/SimpleTexturedOpenGL/CMakeLists.txt b/samples/SimpleTexturedOpenGL/CMakeLists.txt index 6c34acda5..1b206af50 100644 --- a/samples/SimpleTexturedOpenGL/CMakeLists.txt +++ b/samples/SimpleTexturedOpenGL/CMakeLists.txt @@ -11,6 +11,11 @@ IF ( NOT GLUT_FOUND ) ENDIF ( MSVC ) ENDIF ( NOT GLUT_FOUND ) +if ( MSVC ) + ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS ) + ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS ) +endif ( MSVC ) + INCLUDE_DIRECTORIES( ${Assimp_SOURCE_DIR}/include ${Assimp_SOURCE_DIR}/code diff --git a/tools/assimp_view/stdafx.h b/tools/assimp_view/stdafx.h index 3c78d385c..35104d4b0 100644 --- a/tools/assimp_view/stdafx.h +++ b/tools/assimp_view/stdafx.h @@ -23,7 +23,6 @@ #define _WIN32_IE 0x0600 // Ändern Sie dies in den geeigneten Wert für andere Versionen von IE. #endif -#define WIN32_LEAN_AND_MEAN // Selten verwendete Teile der Windows-Header nicht einbinden. // Windows-Headerdateien: #include From 539410d033f0606e444601ab2224bb70ce52c9a5 Mon Sep 17 00:00:00 2001 From: Jared Mulconry Date: Sun, 24 Sep 2017 19:31:04 +1000 Subject: [PATCH 2/7] Fixed an error when compiling samples under MSVC that was caused by assuming including windows.h would pull in shellapi.h --- .../SimpleTexturedOpenGL/src/model_loading.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp index 083650f96..df05b56c4 100644 --- a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp +++ b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp @@ -13,6 +13,7 @@ // http://nehe.gamedev.net/ // ---------------------------------------------------------------------------- #include +#include #include #include #include @@ -666,7 +667,7 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format - bits, // Select Our Color Depth + BYTE(bits), // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored From 8dabd76e03016b9efdffbfce2ef2e7d1fa9db403 Mon Sep 17 00:00:00 2001 From: Jared Mulconry Date: Sun, 24 Sep 2017 21:19:03 +1000 Subject: [PATCH 3/7] Fixed a warning caused by aiVector3D appearing in a packed struct, causing it to fail to pack as requested. --- code/MDLFileData.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/MDLFileData.h b/code/MDLFileData.h index 2afea8a95..3ef58ca5a 100644 --- a/code/MDLFileData.h +++ b/code/MDLFileData.h @@ -126,16 +126,16 @@ struct Header { int32_t version; //! scale factors for each axis - aiVector3D scale; + ai_real scale[3]; //! translation factors for each axis - aiVector3D translate; + ai_real translate[3]; //! bounding radius of the mesh float boundingradius; //! Position of the viewer's exe. Ignored - aiVector3D vEyePos; + ai_real vEyePos[3]; //! Number of textures int32_t num_skins; From 79a51651068b5b5bef4d7b609a7301d9f6790b89 Mon Sep 17 00:00:00 2001 From: Jared Mulconry Date: Sun, 24 Sep 2017 21:46:15 +1000 Subject: [PATCH 4/7] Fixed unused variable warning by replacing them with descriptive comments --- code/FBXBinaryTokenizer.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/FBXBinaryTokenizer.cpp b/code/FBXBinaryTokenizer.cpp index 46e85d888..ede32d7b7 100644 --- a/code/FBXBinaryTokenizer.cpp +++ b/code/FBXBinaryTokenizer.cpp @@ -439,11 +439,11 @@ void TokenizeBinary(TokenList& output_tokens, const char* input, unsigned int le } const char* cursor = input + 18; - const uint8_t unknown_1 = ReadByte(input, cursor, input + length); - const uint8_t unknown_2 = ReadByte(input, cursor, input + length); - const uint8_t unknown_3 = ReadByte(input, cursor, input + length); - const uint8_t unknown_4 = ReadByte(input, cursor, input + length); - const uint8_t unknown_5 = ReadByte(input, cursor, input + length); + /*Result ignored*/ ReadByte(input, cursor, input + length); + /*Result ignored*/ ReadByte(input, cursor, input + length); + /*Result ignored*/ ReadByte(input, cursor, input + length); + /*Result ignored*/ ReadByte(input, cursor, input + length); + /*Result ignored*/ ReadByte(input, cursor, input + length); const uint32_t version = ReadWord(input, cursor, input + length); const bool is64bits = version >= 7500; while (cursor < input + length) From 7e91ac34436d8f0708e1b43cbe5b4f2e3885e9a8 Mon Sep 17 00:00:00 2001 From: Jared Mulconry Date: Mon, 25 Sep 2017 20:22:06 +1000 Subject: [PATCH 5/7] Suppressed warning on gcc caused by the 'visibility' attribute being ignored on types. --- include/assimp/scene.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/assimp/scene.h b/include/assimp/scene.h index 4d027456c..342c316d6 100644 --- a/include/assimp/scene.h +++ b/include/assimp/scene.h @@ -60,6 +60,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. extern "C" { #endif +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wattributes" +#endif + // ------------------------------------------------------------------------------- /** * A node in the imported hierarchy. @@ -163,6 +168,9 @@ struct ASSIMP_API aiNode #endif // __cplusplus }; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif // ------------------------------------------------------------------------------- /** From f6fc5a7a117ea41e43b0bdb1426e9b319924d8fd Mon Sep 17 00:00:00 2001 From: Jared Mulconry Date: Mon, 25 Sep 2017 22:07:01 +1000 Subject: [PATCH 6/7] Changed the FileSizeTest to not rely on tmpnam to eliminate warning on gcc. --- test/unit/utDefaultIOStream.cpp | 47 ++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/test/unit/utDefaultIOStream.cpp b/test/unit/utDefaultIOStream.cpp index 9c1beb193..9ef2bad86 100644 --- a/test/unit/utDefaultIOStream.cpp +++ b/test/unit/utDefaultIOStream.cpp @@ -39,6 +39,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------*/ #include #include "TestIOStream.h" +#include +#include +#include + +#if defined(__GNUC__) || defined(__clang__) +#define MAKE_TEMP_FILE_NAME mktemp +#elif defined(_MSC_VER) +#include +#define MAKE_TEMP_FILE_NAME _mktemp +#endif using namespace ::Assimp; @@ -46,16 +56,33 @@ class utDefaultIOStream : public ::testing::Test { // empty }; -TEST_F( utDefaultIOStream, FileSizeTest ) { - char buffer[ L_tmpnam ]; - tmpnam( buffer ); - std::FILE *fs( std::fopen( buffer, "w+" ) ); - size_t written( std::fwrite( buffer, 1, sizeof( char ) * L_tmpnam, fs ) ); - EXPECT_NE( 0U, written ); - std::fflush( fs ); - TestDefaultIOStream myStream( fs, buffer ); + +const char data[]{"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Qui\ +sque luctus sem diam, ut eleifend arcu auctor eu. Vestibulum id est vel nulla l\ +obortis malesuada ut sed turpis. Nulla a volutpat tortor. Nunc vestibulum portt\ +itor sapien ornare sagittis volutpat."}; + +TEST_F( utDefaultIOStream, FileSizeTest ) { + const auto dataSize = sizeof(data); + const auto dataCount = dataSize / sizeof(*data); + + char fpath[] = { "./rndfp.XXXXXX" }; + auto tmplate = MAKE_TEMP_FILE_NAME(fpath); + ASSERT_NE(tmplate, nullptr); + + //char buffer[ L_tmpnam ]; + //tmpnam( buffer ); + auto *fs = std::fopen(fpath, "w+" ); + ASSERT_NE(fs, nullptr); + auto written = std::fwrite(data, sizeof(*data), dataCount, fs ); + EXPECT_NE( 0U, written ); + auto vflush = std::fflush( fs ); + ASSERT_EQ(vflush, 0); + + TestDefaultIOStream myStream( fs, fpath); size_t size = myStream.FileSize(); - EXPECT_EQ( size, sizeof( char ) * L_tmpnam ); - remove( buffer ); + EXPECT_EQ( size, dataSize); + remove(fpath); + } From 4360267cb22daec5e7e35d4b96d56dac4879feb5 Mon Sep 17 00:00:00 2001 From: Jared Mulconry Date: Mon, 25 Sep 2017 22:58:47 +1000 Subject: [PATCH 7/7] Replaced flakey macros with specific functions to serve the purpose --- test/unit/utDefaultIOStream.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/test/unit/utDefaultIOStream.cpp b/test/unit/utDefaultIOStream.cpp index 9ef2bad86..9335007ba 100644 --- a/test/unit/utDefaultIOStream.cpp +++ b/test/unit/utDefaultIOStream.cpp @@ -44,10 +44,20 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #if defined(__GNUC__) || defined(__clang__) -#define MAKE_TEMP_FILE_NAME mktemp +#define TMP_PATH "/tmp/" +void MakeTmpFilePath(char* tmplate) +{ + auto err = mkstemp(tmplate); + ASSERT_NE(err, -1); +} #elif defined(_MSC_VER) #include -#define MAKE_TEMP_FILE_NAME _mktemp +#define TMP_PATH "./" +void MakeTmpFilePath(char* tmplate) +{ + auto pathtemplate = _mktemp(tmplate); + ASSERT_NE(pathtemplate, nullptr); +} #endif using namespace ::Assimp; @@ -67,12 +77,9 @@ TEST_F( utDefaultIOStream, FileSizeTest ) { const auto dataSize = sizeof(data); const auto dataCount = dataSize / sizeof(*data); - char fpath[] = { "./rndfp.XXXXXX" }; - auto tmplate = MAKE_TEMP_FILE_NAME(fpath); - ASSERT_NE(tmplate, nullptr); + char fpath[] = { TMP_PATH"rndfp.XXXXXX" }; + MakeTmpFilePath(fpath); - //char buffer[ L_tmpnam ]; - //tmpnam( buffer ); auto *fs = std::fopen(fpath, "w+" ); ASSERT_NE(fs, nullptr); auto written = std::fwrite(data, sizeof(*data), dataCount, fs );