Skip to content

PYBIND11_NUMPY_DTYPE does not work on structure containing array #800

@bmerry

Description

@bmerry

Issue description

Using PYBIND11_NUMPY_DTYPE on a structure member which is an array (either a language array or std::array) leads to a compilation error:

pybind11/numpy.h:1027:9: error: ‘format’ is not a member of ‘pybind11::format_descriptor<int [2]>’
         ::pybind11::format_descriptor<decltype(std::declval<T>().Field)>::format(),           \
         ^

Reproducible example code

#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <array>
#include <cstdint>

namespace py = pybind11;

struct foo
{
    std::int32_t array[2];
};

PYBIND11_PLUGIN(arraytest)
{
    PYBIND11_NUMPY_DTYPE(foo, array);

    py::module m("arraytest", "doc");
    return m.ptr();
}

Compiled with GCC 5.4 with g++ -std=c++14 -c pybind11-array.cpp plus -I options for Python and pybind11, and pybind11 version 2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions