From c8e9e15f8e51a3e0f2e690c642b6b4a4e3edc8d4 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Tue, 20 May 2014 12:06:25 -0700 Subject: [PATCH 1/4] Better handling of stdint.h and defines. Try more ways to ensure that __STDC_LIMIT_MACROS is defined before we include stdint.h. And, when we really need its defines, if they didn't come through, try to give a clear error message. --- CMakeLists.txt | 2 ++ src/include/OpenImageIO/fmath.h | 5 ++++- src/include/OpenImageIO/image_view.h | 17 +++++++++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ed4665e..8bc96a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,8 @@ if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCC) # CMake doesn't automatically know what do do with # include_directories(SYSTEM...) when using clang or gcc. set (CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") + # Ensure this macro is set for stdint.h + add_definitions ("-D__STDC_LIMIT_MACROS") endif () if (CMAKE_COMPILER_IS_CLANG) diff --git a/src/include/OpenImageIO/fmath.h b/src/include/OpenImageIO/fmath.h index 33b90b3..367df8a 100644 --- a/src/include/OpenImageIO/fmath.h +++ b/src/include/OpenImageIO/fmath.h @@ -61,7 +61,10 @@ # define _UINT64_T # endif #else -# include +# ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS /* needed for some defs in stdint.h */ +# endif +# include #endif #if defined(__FreeBSD__) diff --git a/src/include/OpenImageIO/image_view.h b/src/include/OpenImageIO/image_view.h index cffa0e1..981eb52 100644 --- a/src/include/OpenImageIO/image_view.h +++ b/src/include/OpenImageIO/image_view.h @@ -32,13 +32,22 @@ #pragma once -#ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS /* needed for some defs in stdint.h */ -#endif - #include #include + +// We're including stdint.h to get int64_t and INT64_MIN. But on some +// platforms, stdint.h only defines them if __STDC_LIMIT_MACROS is defined, +// so we do so. But, oops, if user code included stdint.h before this file, +// and without defining the macro, it may have had ints one and only include +// and not seen the definitions we need, so at least try to make a helpful +// compile-time error in that case. +#ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS /* needed for some defs in stdint.h */ +#endif #include +#if ! defined(INT64_MIN) +# error You must define __STDC_LIMIT_MACROS prior to including stdint.h +#endif #include "oiioversion.h" #include "strided_ptr.h" -- 1.9.3 From 338f58ac9433dc2c064c4cfe840f51809abe68d3 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Tue, 20 May 2014 12:54:10 -0700 Subject: [PATCH 2/4] Improve warning suppression for recent gcc --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bc96a8..509e95c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,11 +82,14 @@ if (CMAKE_COMPILER_IS_CLANG) add_definitions ("-Wunused-private-field") # disable warning about unused command line arguments add_definitions ("-Qunused-arguments") + # Don't warn if we ask it not to warn about warnings it doesn't know + add_definitions ("-Wunknown-warning-option") endif () -if (CMAKE_COMPILER_IS_GNUCC AND (NOT ${GCC_VERSION} VERSION_LESS 4.8)) +if (CMAKE_COMPILER_IS_GNUCC AND (NOT CMAKE_COMPILER_IS_CLANG) AND (NOT ${GCC_VERSION} VERSION_LESS 4.8)) # suppress a warning that Boost::Python hits in g++ 4.8 add_definitions ("-Wno-error=unused-local-typedefs") + add_definitions ("-Wunused-local-typedefs") endif () if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCC) -- 1.9.3 From 1e086bcbc491c9bd2f26cf6f260ef5696e6c1af1 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Tue, 20 May 2014 14:37:56 -0700 Subject: [PATCH 3/4] SPI compiler diddling --- site/spi/Makefile-bits-arnold | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/site/spi/Makefile-bits-arnold b/site/spi/Makefile-bits-arnold index dfd70e1..422fb35 100644 --- a/site/spi/Makefile-bits-arnold +++ b/site/spi/Makefile-bits-arnold @@ -67,15 +67,25 @@ ifeq ($(SP_OS), spinux1) endif ifeq (${COMPILER}, gcc463) - MY_CMAKE_FLAGS += \ + MY_CMAKE_FLAGS += \ -DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.6.3-test/bin/gcc \ -DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.6.3-test/bin/g++ endif ifeq (${COMPILER}, gcc470) - MY_CMAKE_FLAGS += \ + MY_CMAKE_FLAGS += \ -DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.0-test/bin/gcc \ -DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.0-test/bin/g++ endif + ifeq (${COMPILER}, gcc472) + MY_CMAKE_FLAGS += \ + -DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.2-test/bin/gcc \ + -DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.7.2-test/bin/g++ + endif + ifeq (${COMPILER}, gcc490) + MY_CMAKE_FLAGS += \ + -DCMAKE_C_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.9-20130512-test/bin/gcc \ + -DCMAKE_CXX_COMPILER=/net/soft_scratch/apps/arnold/tools/gcc-4.9-20130512-test/bin/g++ + endif ifneq (,$(wildcard /usr/include/OpenEXR2)) MY_CMAKE_FLAGS += \ -- 1.9.3 From 39c28a09702f1726061f917be99f7ec22b12e39a Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Tue, 20 May 2014 14:47:46 -0700 Subject: [PATCH 4/4] Fix confusion of stride_t vs ptrdiff_t for platforms where they're differen --- src/include/OpenImageIO/array_view.h | 12 ++++++------ src/include/OpenImageIO/image_view.h | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/include/OpenImageIO/array_view.h b/src/include/OpenImageIO/array_view.h index 0b9e18c..ffa6ee9 100644 --- a/src/include/OpenImageIO/array_view.h +++ b/src/include/OpenImageIO/array_view.h @@ -223,7 +223,7 @@ class array_view_strided { array_view_strided (T *data, size_t len) { init(data,len); } /// Construct from T*, length, and stride (in bytes). - array_view_strided (T *data, size_t len, ptrdiff_t stride) { + array_view_strided (T *data, size_t len, stride_t stride) { init(data,len,stride); } @@ -263,7 +263,7 @@ class array_view_strided { size_type size() const { return m_len; } size_type max_size() const { return m_len; } bool empty() const { return m_len == 0; } - ptrdiff_t stride() const { return m_stride; } + stride_t stride() const { return m_stride; } const T& operator[] (size_type pos) const { return get(pos); } const T& at (size_t pos) const { @@ -310,17 +310,17 @@ class array_view_strided { private: T * m_data; size_t m_len; - ptrdiff_t m_stride; + stride_t m_stride; - void init (T *data, size_t len, ptrdiff_t stride=AutoStride) { + void init (T *data, size_t len, stride_t stride=AutoStride) { m_data = data; m_len = len; m_stride = stride == AutoStride ? sizeof(T) : stride; } - inline T* getptr (ptrdiff_t pos=0) const { + inline T* getptr (stride_t pos=0) const { return (T*)((char *)m_data + pos*m_stride); } - inline T& get (ptrdiff_t pos=0) const { + inline T& get (stride_t pos=0) const { return *getptr(pos); } diff --git a/src/include/OpenImageIO/image_view.h b/src/include/OpenImageIO/image_view.h index 981eb52..efdcbb2 100644 --- a/src/include/OpenImageIO/image_view.h +++ b/src/include/OpenImageIO/image_view.h @@ -83,8 +83,8 @@ class image_view { /// bytes). image_view (T *data, int nchannels, int width, int height, int depth=1, - ptrdiff_t chanstride=AutoStride, ptrdiff_t xstride=AutoStride, - ptrdiff_t ystride=AutoStride, ptrdiff_t zstride=AutoStride) { + stride_t chanstride=AutoStride, stride_t xstride=AutoStride, + stride_t ystride=AutoStride, stride_t zstride=AutoStride) { init (data, nchannels, width, height, depth, chanstride, xstride, ystride, zstride); } @@ -110,10 +110,10 @@ class image_view { int height() const { return m_height; } int depth() const { return m_depth; } - ptrdiff_t chanstride() const { return m_chanstride; } - ptrdiff_t xstride() const { return m_xstride; } - ptrdiff_t ystride() const { return m_ystride; } - ptrdiff_t zstride() const { return m_zstride; } + stride_t chanstride() const { return m_chanstride; } + stride_t xstride() const { return m_xstride; } + stride_t ystride() const { return m_ystride; } + stride_t zstride() const { return m_zstride; } const T* data() const { return m_data; } @@ -122,12 +122,12 @@ class image_view { private: const T * m_data; int m_nchannels, m_width, m_height, m_depth; - ptrdiff_t m_chanstride, m_xstride, m_ystride, m_zstride; + stride_t m_chanstride, m_xstride, m_ystride, m_zstride; void init (T *data, int nchannels, int width, int height, int depth=1, - ptrdiff_t chanstride=AutoStride, ptrdiff_t xstride=AutoStride, - ptrdiff_t ystride=AutoStride, ptrdiff_t zstride=AutoStride) { + stride_t chanstride=AutoStride, stride_t xstride=AutoStride, + stride_t ystride=AutoStride, stride_t zstride=AutoStride) { m_data = data; m_nchannels = nchannels; m_width = width; m_height = height; m_depth = depth; -- 1.9.3