Fix more MSVC and GCC compilation warnings
This commit is contained in:
parent
f8c279e6db
commit
978770c161
@ -175,5 +175,31 @@ typedef double gmio_float64_t;
|
||||
# define GMIO_C_LINKAGE_END
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 /* Visual C++ 2008 */
|
||||
# define GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE(__code__) \
|
||||
__pragma(warning(push)) \
|
||||
__pragma(warning(disable: __code__))
|
||||
# define GMIO_PRAGMA_MSVC_WARNING_POP() \
|
||||
__pragma(warning(pop))
|
||||
#else
|
||||
/*! MSVC specific macro that disable the compiler warning of code \p __code__
|
||||
*
|
||||
* With Visual C++, expands to :
|
||||
* \code
|
||||
* #pragma warning(push)
|
||||
* #pragma warning(disable: __code__)
|
||||
* \endcode
|
||||
*/
|
||||
# define GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE(__code__)
|
||||
/*! MSVC specific macro that pop the changes made after last warning(pop)
|
||||
*
|
||||
* With Visual C++, expands to :
|
||||
* \code
|
||||
* #pragma warning(pop)
|
||||
* \endcode
|
||||
*/
|
||||
# define GMIO_PRAGMA_MSVC_WARNING_POP()
|
||||
#endif
|
||||
|
||||
#endif /* GMIO_GLOBAL_H */
|
||||
/*! @} */
|
||||
|
@ -29,6 +29,11 @@
|
||||
|
||||
enum { GMIO_FIXED_BUFFER_SIZE = 512 };
|
||||
|
||||
GMIO_INLINE gmio_streamsize_t gmio_stlb_streamsize(uint32_t facet_count)
|
||||
{
|
||||
return GMIO_STLB_HEADER_SIZE + 4 + facet_count*GMIO_STLB_TRIANGLE_RAWSIZE;
|
||||
}
|
||||
|
||||
gmio_stl_format_t gmio_stl_get_format(gmio_stream_t *stream)
|
||||
{
|
||||
char fixed_buffer[GMIO_FIXED_BUFFER_SIZE] = {0};
|
||||
@ -55,19 +60,13 @@ gmio_stl_format_t gmio_stl_get_format(gmio_stream_t *stream)
|
||||
uint32_t facet_count =
|
||||
gmio_decode_uint32_le((const uint8_t*)fixed_buffer + 80);
|
||||
|
||||
if ((GMIO_STLB_HEADER_SIZE + 4 + facet_count*GMIO_STLB_TRIANGLE_RAWSIZE)
|
||||
== stream_size)
|
||||
{
|
||||
if (gmio_stlb_streamsize(facet_count) == stream_size)
|
||||
return GMIO_STL_FORMAT_BINARY_LE;
|
||||
}
|
||||
|
||||
/* Try with byte-reverted facet count */
|
||||
/* Try with big-endian format */
|
||||
facet_count = gmio_uint32_bswap(facet_count);
|
||||
if ((GMIO_STLB_HEADER_SIZE + 4 + facet_count*GMIO_STLB_TRIANGLE_RAWSIZE)
|
||||
== stream_size)
|
||||
{
|
||||
if (gmio_stlb_streamsize(facet_count) == stream_size)
|
||||
return GMIO_STL_FORMAT_BINARY_BE;
|
||||
}
|
||||
}
|
||||
|
||||
/* ASCII STL ? */
|
||||
|
@ -78,9 +78,11 @@ const char* test_core__buffer()
|
||||
const char* test_core__endian()
|
||||
{
|
||||
UTEST_ASSERT(gmio_host_endianness() == GMIO_ENDIANNESS_HOST);
|
||||
GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE(4127)
|
||||
UTEST_ASSERT(GMIO_ENDIANNESS_LITTLE != GMIO_ENDIANNESS_BIG);
|
||||
UTEST_ASSERT(GMIO_ENDIANNESS_HOST == GMIO_ENDIANNESS_LITTLE
|
||||
|| GMIO_ENDIANNESS_HOST == GMIO_ENDIANNESS_BIG);
|
||||
GMIO_PRAGMA_MSVC_WARNING_POP()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user