Browse Source

python: silence annoying GCC 4.8 warnings.

appveyor-coverage
Vladimír Vondruš 7 years ago
parent
commit
ff9003d10c
  1. 5
      src/python/corrade/PyBuffer.h
  2. 6
      src/python/corrade/containers.cpp
  3. 3
      src/python/magnum/math.matrix.h
  4. 3
      src/python/magnum/math.vector.h

5
src/python/corrade/PyBuffer.h

@ -50,8 +50,9 @@ template<class Class, bool(*getter)(Class&, Py_buffer&, int)> void enableBetterB
CORRADE_INTERNAL_ASSERT(!PyErr_Occurred() && buffer);
/* Zero-initialize the output and ask the class to fill it. If that
fails for some reason, give up */
*buffer = Py_buffer{};
fails for some reason, give up. Need to list all members otherwise
GCC 4.8 loudly complains about missing initializers. */
*buffer = Py_buffer{nullptr, nullptr, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr};
if(!getter(pyInstanceFromHandle<Class>(obj), *buffer, flags)) {
CORRADE_INTERNAL_ASSERT(!buffer->obj);
CORRADE_INTERNAL_ASSERT(PyErr_Occurred());

6
src/python/corrade/containers.cpp

@ -109,7 +109,8 @@ template<class T> void arrayView(py::class_<Containers::ArrayView<T>, Containers
/* Buffer protocol */
.def(py::init([](py::buffer other) {
Py_buffer buffer{};
/* GCC 4.8 otherwise loudly complains about missing initializers */
Py_buffer buffer{nullptr, nullptr, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr};
if(PyObject_GetBuffer(other.ptr(), &buffer, (std::is_const<T>::value ? 0 : PyBUF_WRITABLE)) != 0)
throw py::error_already_set{};
@ -312,7 +313,8 @@ template<unsigned dimensions, class T> void stridedArrayView(py::class_<Containe
/* Buffer protocol */
.def(py::init([](py::buffer other) {
Py_buffer buffer{};
/* GCC 4.8 otherwise loudly complains about missing initializers */
Py_buffer buffer{nullptr, nullptr, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr};
if(PyObject_GetBuffer(other.ptr(), &buffer, PyBUF_STRIDES|(std::is_const<T>::value ? 0 : PyBUF_WRITABLE)) != 0)
throw py::error_already_set{};

3
src/python/magnum/math.matrix.h

@ -107,7 +107,8 @@ template<class T, class ...Args> void everyRectangularMatrixBuffer(py::class_<T,
layouts. Has to be defined *before* the from-tuple constructor so it
gets precedence for types that implement the buffer protocol. */
.def(py::init([](py::buffer other) {
Py_buffer buffer{};
/* GCC 4.8 otherwise loudly complains about missing initializers */
Py_buffer buffer{nullptr, nullptr, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr};
if(PyObject_GetBuffer(other.ptr(), &buffer, PyBUF_FORMAT|PyBUF_STRIDES) != 0)
throw py::error_already_set{};

3
src/python/magnum/math.vector.h

@ -132,7 +132,8 @@ template<class T, class ...Args> void everyVectorBuffer(py::class_<T, Args...>&
arrays of non-default types somehow doesn't work. There's also the
other part in vectorBuffer(). */
.def(py::init([](py::buffer other) {
Py_buffer buffer{};
/* GCC 4.8 otherwise loudly complains about missing initializers */
Py_buffer buffer{nullptr, nullptr, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr};
if(PyObject_GetBuffer(other.ptr(), &buffer, PyBUF_FORMAT|PyBUF_STRIDES) != 0)
throw py::error_already_set{};

Loading…
Cancel
Save