building gr-iio for gnuradio 3.9.0 with pybind11

Hello,

I am trying to build gr-iio for gnuradio 3.9 without swig support.  I have tried to follow the instructions at https://wiki.gnuradio.org/index.php/GNU_Radio_3.9_OOT_Module_Porting_Guide . I began with gr-iio maint-3.8 branch and converted it per the porting guide.  I have most of the build working, but I get an error during the pybind portion of the build.

I get error: invalid use of incomplete type ‘struct iio_channel’

[ 67%] Building CXX object python/iio/bindings/CMakeFiles/iio_python.dir/converter_ss_python.cc.o
cd /home/chris/src/iio/gr-iio/build/python/iio/bindings && /usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_DATE_TIME_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_REGEX_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_THREAD_DYN_LINK -DBOOST_UNIT_TEST_FRAMEWORK_DYN_LINK -DFFTW3F_THREADS -DGR_CTRLPORT -Diio_python_EXPORTS -I/home/chris/src/iio/gr-iio/build/python/iio/bindings -I/home/chris/src/iio/gr-iio/python/iio/bindings/../../../lib -I/home/chris/src/iio/gr-iio/python/iio/bindings/../../../include -I/home/chris/src/iio/gr-iio/lib/../include -I/home/chris/src/iio/gr-iio/build/lib -isystem /usr/include/python3.8 -isystem /usr/lib/python3.8/site-packages/numpy/core/include -isystem /opt/gnuradio/include -O3 -DNDEBUG -fPIC -fvisibility=hidden -fvisibility=hidden -flto -fno-fat-lto-objects -Wno-unused-variable -std=gnu++11 -o CMakeFiles/iio_python.dir/converter_ss_python.cc.o -c /home/chris/src/iio/gr-iio/python/iio/bindings/converter_ss_python.cc
In file included from /usr/include/c++/10.2.0/bits/stl_iterator_base_types.h:67,
from /usr/include/c++/10.2.0/bits/forward_list.h:36,
from /usr/include/c++/10.2.0/forward_list:38,
from /usr/include/python3.8/pybind11/detail/common.h:143,
from /usr/include/python3.8/pybind11/pytypes.h:12,
from /usr/include/python3.8/pybind11/cast.h:13,
from /usr/include/python3.8/pybind11/attr.h:13,
from /usr/include/python3.8/pybind11/pybind11.h:44,
from /usr/include/python3.8/pybind11/complex.h:12,
from /home/chris/src/iio/gr-iio/python/iio/bindings/converter_ss_python.cc:20:
/usr/include/c++/10.2.0/type_traits: In instantiation of ‘struct std::is_base_of<pybind11::detail::pyobject_tag, iio_channel>’:
/usr/include/c++/10.2.0/tuple:69:28: recursively required by substitution of ‘template<class T> class pybind11::detail::type_caster<T, typename std::enable_if<std::is_base_of<pybind11::detail::pyobject_tag, typename std::remove_reference<_Tp>::type>::value, void>::type> [with T = iio_channel]’
/usr/include/c++/10.2.0/tuple:69:28: required from ‘struct std::_Tuple_impl<1, pybind11::detail::type_caster<iio_channel, void>, pybind11::detail::type_caster<bool, void> >’
/usr/include/c++/10.2.0/tuple:191:12: required from ‘struct std::_Tuple_impl<0, pybind11::detail::type_caster<pybind11::detail::value_and_holder, void>, pybind11::detail::type_caster<iio_channel, void>, pybind11::detail::type_caster<bool, void> >’
/usr/include/c++/10.2.0/tuple:516:11: required from ‘class std::tuple<pybind11::detail::type_caster<pybind11::detail::value_and_holder, void>, pybind11::detail::type_caster<iio_channel, void>, pybind11::detail::type_caster<bool, void> >’
/usr/include/python3.8/pybind11/cast.h:1985:38: required from ‘class pybind11::detail::argument_loader<pybind11::detail::value_and_holder&, const iio_channel*, bool>’
/usr/include/python3.8/pybind11/pybind11.h:133:77: required from ‘void pybind11::cpp_function::initialize(Func&&, Return (*)(Args ...), const Extra& ...) [with Func = pybind11::detail::initimpl::factory<Func, pybind11::detail::void_type (*)(), Return(Args ...)>::execute<pybind11::class_<gr::iio::converter_ss, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss> >, {pybind11::arg, pybind11::arg, const char*}>::<lambda(pybind11::detail::value_and_holder&, const iio_channel*, bool)>; Return = void; Args = {pybind11::detail::value_and_holder&, const iio_channel*, bool}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::detail::is_new_style_constructor, pybind11::arg, pybind11::arg, const char*}]’
/usr/include/python3.8/pybind11/pybind11.h:71:19: required from ‘pybind11::cpp_function::cpp_function(Func&&, const Extra& ...) [with Func = pybind11::detail::initimpl::factory<Func, pybind11::detail::void_type (*)(), Return(Args ...)>::execute<pybind11::class_<gr::iio::converter_ss, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss> >, {pybind11::arg, pybind11::arg, const char*}>::<lambda(pybind11::detail::value_and_holder&, const iio_channel*, bool)>; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::detail::is_new_style_constructor, pybind11::arg, pybind11::arg, const char*}; <template-parameter-1-3> = void]’
/usr/include/python3.8/pybind11/pybind11.h:1118:22: required from ‘pybind11::class_<type_, options>& pybind11::class_<type_, options>::def(const char*, Func&&, const Extra& ...) [with Func = pybind11::detail::initimpl::factory<Func, pybind11::detail::void_type (*)(), Return(Args ...)>::execute<pybind11::class_<gr::iio::converter_ss, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss> >, {pybind11::arg, pybind11::arg, const char*}>::<lambda(pybind11::detail::value_and_holder&, const iio_channel*, bool)>; Extra = {pybind11::detail::is_new_style_constructor, pybind11::arg, pybind11::arg, const char*}; type_ = gr::iio::converter_ss; options = {gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss>}]’
/usr/include/python3.8/pybind11/detail/init.h:234:15: required from ‘void pybind11::detail::initimpl::factory<Func, pybind11::detail::void_type (*)(), Return(Args ...)>::execute(Class&, const Extra& ...) && [with Class = pybind11::class_<gr::iio::converter_ss, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss> >; Extra = {pybind11::arg, pybind11::arg, const char*}; Func = std::shared_ptr<gr::iio::converter_ss> (*)(const iio_channel*, bool); Return = std::shared_ptr<gr::iio::converter_ss>; Args = {const iio_channel*, bool}]’
/usr/include/python3.8/pybind11/pybind11.h:1160:32: required from ‘pybind11::class_<type_, options>& pybind11::class_<type_, options>::def(pybind11::detail::initimpl::factory<Args ...>&&, const Extra& ...) [with Args = {std::shared_ptr<gr::iio::converter_ss> (*)(const iio_channel*, bool), pybind11::detail::void_type (*)(), std::shared_ptr<gr::iio::converter_ss>(const iio_channel*, bool), pybind11::detail::void_type()}; Extra = {pybind11::arg, pybind11::arg, const char*}; type_ = gr::iio::converter_ss; options = {gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss>}]’
/home/chris/src/iio/gr-iio/python/iio/bindings/converter_ss_python.cc:43:9: required from here
/usr/include/c++/10.2.0/type_traits:1412:38: error: invalid use of incomplete type ‘struct iio_channel’
1412 | : public integral_constant<bool, __is_base_of(_Base, _Derived)>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/chris/src/iio/gr-iio/python/iio/bindings/converter_ss_python.cc:26:
/home/chris/src/iio/gr-iio/python/iio/bindings/../../../include/iio/converter_ss.h:30:9: note: forward declaration of ‘struct iio_channel’
30 | struct iio_channel;
| ^~~~~~~~~~~
In file included from /usr/include/python3.8/pybind11/cast.h:15,
from /usr/include/python3.8/pybind11/attr.h:13,
from /usr/include/python3.8/pybind11/pybind11.h:44,
from /usr/include/python3.8/pybind11/complex.h:12,
from /home/chris/src/iio/gr-iio/python/iio/bindings/converter_ss_python.cc:20:
/usr/include/python3.8/pybind11/detail/descr.h: In instantiation of ‘static constexpr std::array<const std::type_info*, (sizeof... (Ts) + 1)> pybind11::detail::descr<N, Ts>::types() [with long unsigned int N = 26; Ts = {pybind11::detail::value_and_holder, iio_channel}]’:
/usr/include/python3.8/pybind11/pybind11.h:173:73: required from ‘void pybind11::cpp_function::initialize(Func&&, Return (*)(Args ...), const Extra& ...) [with Func = pybind11::detail::initimpl::factory<Func, pybind11::detail::void_type (*)(), Return(Args ...)>::execute<pybind11::class_<gr::iio::converter_ss, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss> >, {pybind11::arg, pybind11::arg, const char*}>::<lambda(pybind11::detail::value_and_holder&, const iio_channel*, bool)>; Return = void; Args = {pybind11::detail::value_and_holder&, const iio_channel*, bool}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::detail::is_new_style_constructor, pybind11::arg, pybind11::arg, const char*}]’
/usr/include/python3.8/pybind11/pybind11.h:71:19: required from ‘pybind11::cpp_function::cpp_function(Func&&, const Extra& ...) [with Func = pybind11::detail::initimpl::factory<Func, pybind11::detail::void_type (*)(), Return(Args ...)>::execute<pybind11::class_<gr::iio::converter_ss, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss> >, {pybind11::arg, pybind11::arg, const char*}>::<lambda(pybind11::detail::value_and_holder&, const iio_channel*, bool)>; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::detail::is_new_style_constructor, pybind11::arg, pybind11::arg, const char*}; <template-parameter-1-3> = void]’
/usr/include/python3.8/pybind11/pybind11.h:1118:22: required from ‘pybind11::class_<type_, options>& pybind11::class_<type_, options>::def(const char*, Func&&, const Extra& ...) [with Func = pybind11::detail::initimpl::factory<Func, pybind11::detail::void_type (*)(), Return(Args ...)>::execute<pybind11::class_<gr::iio::converter_ss, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss> >, {pybind11::arg, pybind11::arg, const char*}>::<lambda(pybind11::detail::value_and_holder&, const iio_channel*, bool)>; Extra = {pybind11::detail::is_new_style_constructor, pybind11::arg, pybind11::arg, const char*}; type_ = gr::iio::converter_ss; options = {gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss>}]’
/usr/include/python3.8/pybind11/detail/init.h:234:15: required from ‘void pybind11::detail::initimpl::factory<Func, pybind11::detail::void_type (*)(), Return(Args ...)>::execute(Class&, const Extra& ...) && [with Class = pybind11::class_<gr::iio::converter_ss, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss> >; Extra = {pybind11::arg, pybind11::arg, const char*}; Func = std::shared_ptr<gr::iio::converter_ss> (*)(const iio_channel*, bool); Return = std::shared_ptr<gr::iio::converter_ss>; Args = {const iio_channel*, bool}]’
/usr/include/python3.8/pybind11/pybind11.h:1160:32: required from ‘pybind11::class_<type_, options>& pybind11::class_<type_, options>::def(pybind11::detail::initimpl::factory<Args ...>&&, const Extra& ...) [with Args = {std::shared_ptr<gr::iio::converter_ss> (*)(const iio_channel*, bool), pybind11::detail::void_type (*)(), std::shared_ptr<gr::iio::converter_ss>(const iio_channel*, bool), pybind11::detail::void_type()}; Extra = {pybind11::arg, pybind11::arg, const char*}; type_ = gr::iio::converter_ss; options = {gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss>}]’
/home/chris/src/iio/gr-iio/python/iio/bindings/converter_ss_python.cc:43:9: required from here
/usr/include/python3.8/pybind11/detail/descr.h:38:19: error: invalid use of incomplete type ‘struct iio_channel’
38 | return {{&typeid(Ts)..., nullptr}};
| ^~~~~~~~~~
In file included from /home/chris/src/iio/gr-iio/python/iio/bindings/converter_ss_python.cc:26:
/home/chris/src/iio/gr-iio/python/iio/bindings/../../../include/iio/converter_ss.h:30:9: note: forward declaration of ‘struct iio_channel’
30 | struct iio_channel;
| ^~~~~~~~~~~
In file included from /usr/include/python3.8/pybind11/cast.h:15,
from /usr/include/python3.8/pybind11/attr.h:13,
from /usr/include/python3.8/pybind11/pybind11.h:44,
from /usr/include/python3.8/pybind11/complex.h:12,
from /home/chris/src/iio/gr-iio/python/iio/bindings/converter_ss_python.cc:20:
/usr/include/python3.8/pybind11/detail/descr.h:38:42: error: could not convert ‘{{<expression error>, nullptr}}’ from ‘<brace-enclosed initializer list>’ to ‘std::array<const std::type_info*, 3>’
38 | return {{&typeid(Ts)..., nullptr}};
| ^
| |
| <brace-enclosed initializer list>
/usr/include/python3.8/pybind11/detail/descr.h:39:5: error: body of ‘constexpr’ function ‘static constexpr std::array<const std::type_info*, (sizeof... (Ts) + 1)> pybind11::detail::descr<N, Ts>::types() [with long unsigned int N = 26; Ts = {pybind11::detail::value_and_holder, iio_channel}]’ not a return-statement
39 | }
| ^
In file included from /usr/include/python3.8/pybind11/complex.h:12,
from /home/chris/src/iio/gr-iio/python/iio/bindings/converter_ss_python.cc:20:
/usr/include/python3.8/pybind11/pybind11.h: In instantiation of ‘void pybind11::cpp_function::initialize(Func&&, Return (*)(Args ...), const Extra& ...) [with Func = pybind11::detail::initimpl::factory<Func, pybind11::detail::void_type (*)(), Return(Args ...)>::execute<pybind11::class_<gr::iio::converter_ss, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss> >, {pybind11::arg, pybind11::arg, const char*}>::<lambda(pybind11::detail::value_and_holder&, const iio_channel*, bool)>; Return = void; Args = {pybind11::detail::value_and_holder&, const iio_channel*, bool}; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::detail::is_new_style_constructor, pybind11::arg, pybind11::arg, const char*}]’:
/usr/include/python3.8/pybind11/pybind11.h:71:19: required from ‘pybind11::cpp_function::cpp_function(Func&&, const Extra& ...) [with Func = pybind11::detail::initimpl::factory<Func, pybind11::detail::void_type (*)(), Return(Args ...)>::execute<pybind11::class_<gr::iio::converter_ss, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss> >, {pybind11::arg, pybind11::arg, const char*}>::<lambda(pybind11::detail::value_and_holder&, const iio_channel*, bool)>; Extra = {pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::detail::is_new_style_constructor, pybind11::arg, pybind11::arg, const char*}; <template-parameter-1-3> = void]’
/usr/include/python3.8/pybind11/pybind11.h:1118:22: required from ‘pybind11::class_<type_, options>& pybind11::class_<type_, options>::def(const char*, Func&&, const Extra& ...) [with Func = pybind11::detail::initimpl::factory<Func, pybind11::detail::void_type (*)(), Return(Args ...)>::execute<pybind11::class_<gr::iio::converter_ss, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss> >, {pybind11::arg, pybind11::arg, const char*}>::<lambda(pybind11::detail::value_and_holder&, const iio_channel*, bool)>; Extra = {pybind11::detail::is_new_style_constructor, pybind11::arg, pybind11::arg, const char*}; type_ = gr::iio::converter_ss; options = {gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss>}]’
/usr/include/python3.8/pybind11/detail/init.h:234:15: required from ‘void pybind11::detail::initimpl::factory<Func, pybind11::detail::void_type (*)(), Return(Args ...)>::execute(Class&, const Extra& ...) && [with Class = pybind11::class_<gr::iio::converter_ss, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss> >; Extra = {pybind11::arg, pybind11::arg, const char*}; Func = std::shared_ptr<gr::iio::converter_ss> (*)(const iio_channel*, bool); Return = std::shared_ptr<gr::iio::converter_ss>; Args = {const iio_channel*, bool}]’
/usr/include/python3.8/pybind11/pybind11.h:1160:32: required from ‘pybind11::class_<type_, options>& pybind11::class_<type_, options>::def(pybind11::detail::initimpl::factory<Args ...>&&, const Extra& ...) [with Args = {std::shared_ptr<gr::iio::converter_ss> (*)(const iio_channel*, bool), pybind11::detail::void_type (*)(), std::shared_ptr<gr::iio::converter_ss>(const iio_channel*, bool), pybind11::detail::void_type()}; Extra = {pybind11::arg, pybind11::arg, const char*}; type_ = gr::iio::converter_ss; options = {gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<gr::iio::converter_ss>}]’
/home/chris/src/iio/gr-iio/python/iio/bindings/converter_ss_python.cc:43:9: required from here
/usr/include/python3.8/pybind11/pybind11.h:173:73: error: ‘static constexpr std::array<const std::type_info*, (sizeof... (Ts) + 1)> pybind11::detail::descr<N, Ts>::types() [with long unsigned int N = 26; Ts = {pybind11::detail::value_and_holder, iio_channel}]’ called in a constant expression
173 | PYBIND11_DESCR_CONSTEXPR auto types = decltype(signature)::types();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~

In file included from /usr/include/python3.8/pybind11/cast.h:15,
from /usr/include/python3.8/pybind11/attr.h:13,
from /usr/include/python3.8/pybind11/pybind11.h:44,
from /usr/include/python3.8/pybind11/complex.h:12,
from /home/chris/src/iio/gr-iio/python/iio/bindings/converter_ss_python.cc:20:
/usr/include/python3.8/pybind11/detail/descr.h:37:76: note: ‘static constexpr std::array<const std::type_info*, (sizeof... (Ts) + 1)> pybind11::detail::descr<N, Ts>::types() [with long unsigned int N = 26; Ts = {pybind11::detail::value_and_holder, iio_channel}]’ is not usable as a ‘constexpr’ function because:
37 | nstexpr std::array<const std::type_info *, sizeof...(Ts) + 1> types() {
| ^~~~~

make[2]: *** [python/iio/bindings/CMakeFiles/iio_python.dir/build.make:108: python/iio/bindings/CMakeFiles/iio_python.dir/converter_ss_python.cc.o] Error 1
make[2]: Leaving directory '/home/chris/src/iio/gr-iio/build'
make[1]: *** [CMakeFiles/Makefile2:404: python/iio/bindings/CMakeFiles/iio_python.dir/all] Error 2
make[1]: Leaving directory '/home/chris/src/iio/gr-iio/build'
make: *** [Makefile:149: all] Error 2

I have a patch, but it is 700k because of all the gr_modtool bind calls and the addition of the docs directory.  Please indicate in your response if you want it attached to my next post.

Thanks for your time.

Chris