discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Correct usage of gr::io_signature::makev


From: CEL
Subject: Re: [Discuss-gnuradio] Correct usage of gr::io_signature::makev
Date: Sun, 29 Apr 2018 15:35:12 +0000

That certainly works, too!

If you're using C++11, you can also

static std::vector<int> get_input_sizes(){
     std::vector<int> input_sizes = {
         sizeof(gr_complex),
         sizeof(gr_complex),
         sizeof(gr_complex),
         sizeof(gr_complex),
         sizeof(float)
     };
     return input_sizes;
}

Or, even shorter, just:

static std::vector<int> get_input_sizes(){
     return {
         sizeof(gr_complex),
         sizeof(gr_complex),
         sizeof(gr_complex),
         sizeof(gr_complex),
         sizeof(float)
     };
}

since C++11 allows you to just use initializer lists where you'd
normally have to explicitly construct a vector.

On Sun, 2018-04-29 at 16:17 +0200, Sumit Kumar wrote:
> Hi Marcus,
> 
> Ok I did that as you said and it work :)
> 
> Also I found another way. I made a separate method in the class short_sync
> 
> static std::vector<int> get_input_sizes(){
>      std::vector<int> input_sizes;
>      input_sizes.push_back(sizeof(gr_complex));
>      input_sizes.push_back(sizeof(gr_complex));
>      input_sizes.push_back(sizeof(gr_complex));
>      input_sizes.push_back(sizeof(gr_complex));
>      input_sizes.push_back(sizeof(float));
> 
>      return input_sizes;
>      }
> 
> and then call it like this
> 
> gr::io_signature::makev(5, 5, get_input_sizes())
> 
> So both of them work!
> 
> Thanks
> 
> Sumit
> 
> 
> On 28/04/2018 19:13, Marcus Müller wrote:
> > Ah, I got that wrong,
> > 
> > The difference is that fll_band_edge_cc_impl.cc doesn't declare that
> > static variable as class member, but you do – that leads to a problem,
> > because that way, the C++ type sync_short_impl as defined in your
> > _impl.cc differs from the one in the _impl.h, but requires that an
> > object be allocated in memory before the first instance of that type
> > can be allocated. Therefore, in-class defined static members can only
> > be integral types. (And if you didn't understand much of that, don't
> > worry, it only happened to cross my horizon because I introduced a
> > strange bug when I tried to fix PMT usage in GNU Radio, and had to go
> > back, understand a static initialization problem, which took hours, and
> > fix my changes.)
> > 
> > Workaround: don't make ios and iosig a part of the class, but only of
> > the gr::ieee802_11 namespace (and maybe give them more unique names
> > when doing so).
> > 
> > Best regards,
> > Marcus
> > 
> > On Sat, 2018-04-28 at 17:39 +0200, Sumit Kumar wrote:
> > > Hi Marcus,
> > > 
> > > Actually I din't do that since the reference code which I was
> > > following,
> > > i.e.,
> > > 
> > > fll_band_edge_cc_impl.cc, has no such declaration in the
> > > corresponding
> > > header fll_band_edge_cc_impl.h
> > > 
> > > Sumit
> > > 
> > > On 28/04/2018 17:28, Marcus Müller wrote:
> > > > Hi Sumit,
> > > > 
> > > > I don't see where `ios` is being declared constantly and/or
> > > > statically
> > > > before line 31? Does that happen in the header?
> > > > 
> > > > Best regards,
> > > > Marcus
> > > > On Sat, 2018-04-28 at 16:51 +0200, Sumit Kumar wrote:
> > > > > Hi,
> > > > > In order to look for correct usage of gr::io_signature::makev, I
> > > > > checked this example https://github.com/gnuradio/gnuradio/blob/ma
> > > > > ster
> > > > > /gr-digital/lib/fll_band_edge_cc_impl.cc
> > > > > and found
> > > > > static int ios[] = {sizeof(gr_complex), sizeof(gr_complex),
> > > > > sizeof(gr_complex), sizeof(float)};
> > > > > static std::vector<int> iosig(ios, ios+sizeof(ios)/sizeof(int));
> > > > > and then use as io_signature::makev(1, 4, iosig))
> > > > > Basically I have to use it in sync_short.cc from gr-ieee 80211 in
> > > > > order to create more inputs.
> > > > > But if I use the above two lines inside the class i.e.
> > > > > sync_short_impl, I get lots of error. I have attached the file
> > > > > for
> > > > > reference. Could you please suggest me correct usage. I can give
> > > > > more
> > > > > information if needed.
> > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > > > ~~~~
> > > > > ~~~~~~~
> > > > > /home/john/myprefix/src/gr-ieee-80211/lib/sync_short.cc:31:84:
> > > > > error:
> > > > > in-class initialization of static data member ‘int
> > > > > sync_short_impl::ios []’ of incomplete type
> > > > >    tic int ios[] = {sizeof(gr_complex), sizeof(float),
> > > > > sizeof(float),
> > > > > sizeof(float)};
> > > > >                                                                   
> > > > >       
> > > > >               ^
> > > > > /home/john/myprefix/src/gr-ieee-80211/lib/sync_short.cc:32:31:
> > > > > error:
> > > > > ‘ios’ is not a type
> > > > >    static std::vector<int> iosig(ios,
> > > > > ios+sizeof(ios)/sizeof(int));
> > > > >                                  ^
> > > > > /home/john/myprefix/src/gr-ieee-80211/lib/sync_short.cc:32:36:
> > > > > error:
> > > > > ‘ios’ is not a type
> > > > >    static std::vector<int> iosig(ios,
> > > > > ios+sizeof(ios)/sizeof(int));
> > > > >                                       ^
> > > > > /home/john/myprefix/src/gr-ieee-80211/lib/sync_short.cc:32:39:
> > > > > error:
> > > > > expected ‘,’ or ‘...’ before ‘+’ token
> > > > >    static std::vector<int> iosig(ios,
> > > > > ios+sizeof(ios)/sizeof(int));
> > > > >                                          ^
> > > > > /home/john/myprefix/src/gr-ieee-80211/lib/sync_short.cc: In
> > > > > constructor ‘sync_short_impl::sync_short_impl(double, unsigned
> > > > > int,
> > > > > bool, bool)’:
> > > > > /home/john/myprefix/src/gr-ieee-80211/lib/sync_short.cc:35:39:
> > > > > error:
> > > > > no matching function for call to ‘gr::io_signature::makev(int,
> > > > > int,
> > > > > std::vector<int> (&)(int, int))’
> > > > >       gr::io_signature::makev(4, 4, iosig),
> > > > >                                          ^
> > > > > In file included from
> > > > > /home/john/myprefix/include/gnuradio/basic_block.h:30:0,
> > > > >                    from
> > > > > /home/john/myprefix/include/gnuradio/block.h:27,
> > > > >                    from /home/john/myprefix/src/gr-ieee-
> > > > > 80211/include/ieee802-11/sync_short.h:21,
> > > > >                    from /home/john/myprefix/src/gr-ieee-
> > > > > 80211/lib/sync_short.cc:17:
> > > > > /home/john/myprefix/include/gnuradio/io_signature.h:100:17: note:
> > > > > candidate: static gr::io_signature::sptr
> > > > > gr::io_signature::makev(int,
> > > > > int, const std::vector<int>&)
> > > > >        static sptr makev(int min_streams, int max_streams,
> > > > >                    ^
> > > > > /home/john/myprefix/include/gnuradio/io_signature.h:100:17: note:
> > > > > no known conversion for argument 3 from ‘std::vector<int>(int,
> > > > > int)’
> > > > > to ‘const std::vector<int>&’
> > > > > lib/CMakeFiles/gnuradio-ieee802_11.dir/build.make:584: recipe for
> > > > > target 'lib/CMakeFiles/gnuradio-ieee802_11.dir/sync_short.cc.o'
> > > > > failed
> > > > > make[2]: *** [lib/CMakeFiles/gnuradio-
> > > > > ieee802_11.dir/sync_short.cc.o]
> > > > > Error 1
> > > > > CMakeFiles/Makefile2:200: recipe for target
> > > > > 'lib/CMakeFiles/gnuradio-
> > > > > ieee802_11.dir/all' failed
> > > > > make[1]: *** [lib/CMakeFiles/gnuradio-ieee802_11.dir/all] Error 2
> > > > > Makefile:138: recipe for target 'all' failed
> > > > > make: *** [all] Error 2
> > > > > _______________________________________________
> > > > > Discuss-gnuradio mailing list
> > > > > address@hidden
> > > > > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> 
> 
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]