pybind / pybind/pybind11

Static assertion in numpy.h fails when compiling with MINGW GCC

Open
#1,342 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

When compiling this code:

#include "pybind11/pybind11.h"
#include "pybind11/numpy.h"

namespace py=pybind11;

PYBIND11_MODULE(foo,m)
{

}

With mingw GCC 6.3.0 64bit (default flags provided by cmake), I am getting the following error message:

In file included from pybind.cpp:2:0:
C:\{whatever_path_to_my_pybind_includes}/pybind11/numpy.h:35:1: error: static assertion failed: ssize_t != Py_intptr_t
 static_assert(sizeof(ssize_t) == sizeof(Py_intptr_t), "ssize_t != Py_intptr_t");
 ^~~~~~~~~~~~~

To get rid of it, I need to manually add -DMS_WIN64 to the compiler flags. Also, -D_hypot=hypot needs to be added, but this is related to issue #838 .

Is this something that someone might have encountered before?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with pybind11/numpy.h and the reported static assertion, then inspect the CMake compiler flags for the MinGW GCC configuration. Compare the failing minimal module build with one using MS_WIN64, while checking issue #838 for the related _hypot flag. Done means the example compiles without manually adding the reported workaround flags.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, numpy, python
Domain
build-system, compilers, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.