Skip to content

Pedantic Warnings in pytypes.h #1417

@ax3l

Description

@ax3l

Issue description

Seen with gcc 4.8.5 on Ubuntu 14.04:

include/pybind11/pytypes.h: In lambda function:
include/pybind11/pytypes.h:1100:89: error: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Werror=pedantic]
             auto destructor = reinterpret_cast<void (*)(void *)>(PyCapsule_GetContext(o));
                                                                                         ^
include/pybind11/pytypes.h: In constructor ‘pybind11::capsule::capsule(const void*, void (*)(void*))’:
include/pybind11/pytypes.h:1108:50: error: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Werror=pedantic]
         if (PyCapsule_SetContext(m_ptr, (void *) destructor) != 0)
                                                  ^
include/pybind11/pytypes.h: In constructor ‘pybind11::capsule::capsule(void (*)())’:
include/pybind11/pytypes.h:1113:66: error: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Werror=pedantic]
         m_ptr = PyCapsule_New(reinterpret_cast<void *>(destructor), nullptr, [](PyObject *o) {
                                                                  ^
include/pybind11/pytypes.h: In lambda function:
include/pybind11/pytypes.h:1114:92: error: ISO C++ forbids casting between pointer-to-function and pointer-to-object [-Werror=pedantic]
             auto destructor = reinterpret_cast<void (*)()>(PyCapsule_GetPointer(o, nullptr));

Reproducible example code

Compile a pybind11 2.2.3 example with -pedantic and -Werror and gcc 4.8.5.

Metadata

Metadata

Assignees

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