{"action":"created","issue":{"url":"https://api.github.com/repos/pybind/pybind11/issues/416","repository_url":"https://api.github.com/repos/pybind/pybind11","labels_url":"https://api.github.com/repos/pybind/pybind11/issues/416/labels{/name}","comments_url":"https://api.github.com/repos/pybind/pybind11/issues/416/comments","events_url":"https://api.github.com/repos/pybind/pybind11/issues/416/events","html_url":"https://github.com/pybind/pybind11/issues/416","id":177910587,"number":416,"title":"Problem with format_descriptor and integral types in VS2015","user":{"login":"patrikhuber","id":4967343,"avatar_url":"https://avatars.githubusercontent.com/u/4967343?v=3","gravatar_id":"","url":"https://api.github.com/users/patrikhuber","html_url":"https://github.com/patrikhuber","followers_url":"https://api.github.com/users/patrikhuber/followers","following_url":"https://api.github.com/users/patrikhuber/following{/other_user}","gists_url":"https://api.github.com/users/patrikhuber/gists{/gist_id}","starred_url":"https://api.github.com/users/patrikhuber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrikhuber/subscriptions","organizations_url":"https://api.github.com/users/patrikhuber/orgs","repos_url":"https://api.github.com/users/patrikhuber/repos","events_url":"https://api.github.com/users/patrikhuber/events{/privacy}","received_events_url":"https://api.github.com/users/patrikhuber/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2016-09-19T22:04:09Z","updated_at":"2016-09-27T09:48:57Z","closed_at":"2016-09-27T09:24:38Z","body":"This is kind of weird but I think it looks to me like a bug in `format_descriptor` or somewhere related.\r\n\r\nI'm doing this inside a `.def_buffer(... { ...`:\r\n\r\n`std::cout << py::format_descriptor<float>::format() << std::endl;`\r\n\r\nand when I call the appropriate function from python, it outputs \"f\", as expected, and \"d\" if I plug in `double` as T. However when I plug in any other type (integral types I guess), like `unsigned char` or `signed int`, it outputs a blank string.\r\n\r\nI've found the lines `PYBIND11_DECL_FMT(float, \"f\");` for float, double and bool, so the function is not defined for other types, however, there is a function\r\n\r\n`template <typename T> struct format_descriptor<T, typename std::enable_if<std::is_integral<T>::value>::type> {`\r\n\r\nwhich I think should get activated if T is an integral type, however, it doesn't seem to be, as the returned string is an empty \"\".\r\n\r\nAfter a while of pondering over this I thought it might have something to do with the compile flags of pybind11, since in a \"hello-world\" repro in a C++ app, it weirdly prints the correct values, for example `pybind11::format_descriptor<unsigned char>::format()` prints `B`. However I commented all flags I could find like `/LTCG` and so on in pybind11's `CMakeLists.txt`, but there was no change in behaviour.\r\n\r\nInitially, what happened was that my code works correctly for float/double, but when I put in unsigned char's in my data type and `pybind11::format_descriptor<unsigned char>::format()` into the `buffer_info`, python would complain with a `RuntimeWarning: Item size computed from the PEP 3118 buffer format string does not match the actual item size.`. Then, I found out what I described above, that in fact the format string is empty when it should be `B`.\r\n\r\nSorry in case this is something stupid that I overlooked, but I spend quite a lot of time trying to solve this."},"comment":{"url":"https://api.github.com/repos/pybind/pybind11/issues/comments/249818530","html_url":"https://github.com/pybind/pybind11/issues/416#issuecomment-249818530","issue_url":"https://api.github.com/repos/pybind/pybind11/issues/416","id":249818530,"user":{"login":"patrikhuber","id":4967343,"avatar_url":"https://avatars.githubusercontent.com/u/4967343?v=3","gravatar_id":"","url":"https://api.github.com/users/patrikhuber","html_url":"https://github.com/patrikhuber","followers_url":"https://api.github.com/users/patrikhuber/followers","following_url":"https://api.github.com/users/patrikhuber/following{/other_user}","gists_url":"https://api.github.com/users/patrikhuber/gists{/gist_id}","starred_url":"https://api.github.com/users/patrikhuber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrikhuber/subscriptions","organizations_url":"https://api.github.com/users/patrikhuber/orgs","repos_url":"https://api.github.com/users/patrikhuber/repos","events_url":"https://api.github.com/users/patrikhuber/events{/privacy}","received_events_url":"https://api.github.com/users/patrikhuber/received_events","type":"User","site_admin":false},"created_at":"2016-09-27T09:48:57Z","updated_at":"2016-09-27T09:48:57Z","body":"@wjakob I think what you committed doesn't compile - you additionally need to delete these following two lines:\r\n\r\n```\r\ntemplate <typename T> constexpr const char format_descriptor<\r\n    T, detail::enable_if_t<std::is_integral<T>::value>>::value[2];\r\n```\r\n\r\nOtherwise there's an error:\r\n\r\n```\r\ninclude\\pybind11\\common.h(441): error C2039: 'value': is not a member of 'pybind11::format_descriptor<T,std::enable_if<std::is_integral<_Ty>::value,void>::type>'\r\ninclude\\pybind11\\common.h(440): note: see declaration of 'pybind11::format_descriptor<T,std::enable_if<std::is_integral<_Ty>::value,void>::type>'\r\n```"}}
{"actor":{"display_login":"patrikhuber"}}