Hello, I was not originally using 'using name std' in the code, but I will
keep that in mind for future reference. I used using std::byte and that did
not work, but following the cmake link you gave me I was able to enable
c++17 and I now have less errors. Here is what is left if you would like to
take a look at it:

/home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:59:5: error:
expected initializer before ‘my_Random_Byte_Source_impl’
   59 |     my_Random_Byte_Source_impl::get_bytes(const byte &sample)
        |     ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc: In member
function ‘virtual int gr::Random::my_Random_Byte_Source_impl::work(int,
gr_vector_const_void_star&, gr_vector_void_star&)’:
/home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:73:24: error:
‘get_bytes’ was not declared in this scope
   73 |               out[i] = get_bytes(i)
        |                           ^~~~~~~~~
make[2]: *** [lib/CMakeFiles/gnuradio-Random.dir/build.make:63:
lib/CMakeFiles/gnuradio-Random.dir/my_Random_Byte_Source_impl.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:301:
lib/CMakeFiles/gnuradio-Random.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

What do you think? Would you like to see the whole code? or just how I
thought I declared them? Thank you for your time.

On Mon, Nov 8, 2021 at 3:28 PM Jim Melton <jim.mel...@sncorp.com> wrote:

> Probably you’ve fallen prey to the common academic practice of including
> “using namespace std” in your code. In industry, it’s not as common (I
> don’t allow it in my projects).
>
>
>
> *std::byte* is a new type in C++17. If you aren’t using that new of a
> compiler (or didn’t set the required standard in your CMakeLists.txt file),
> it won’t be supported.
>
>
>
> Try replacing *byte* with *std::byte* and never ever write “using
> namespace std” ever again. If that doesn’t work, make sure you enabled
> C++17 (see https://crascit.com/2015/03/28/enabling-cxx11-in-cmake/).
>
>
>
> ---
>
> *Jim Melton*
>
>
>
>
>
> *From:* Discuss-gnuradio <discuss-gnuradio-bounces+jim.melton=
> sncorp....@gnu.org> *On Behalf Of *Mario Moran
> *Sent:* Monday, November 8, 2021 15:06
> *To:* discuss-gnuradio@gnu.org
> *Subject:* [EXTERNAL] Creating my own Random Source
>
>
>
> Good afternoon,
>
>
>
> I know there is already a Random Source, but my advisor would like me to
> create my own out of tree modules and use them in a flowgraph. So, I am
> creating my own block, here are my steps so everyone can see what I have
> done.
>
>
>
> gr_modtool newmod Random
>
> gr_modtool add my_Random_Byte_Source
>
> Block Type: Source
>
> Language: Cpp
>
> No arguments(Side note I might redo this and make arguments but for now it
> will be specific for one need)
>
> Add python QA code: n
>
> Add C++ QA code: y
>
> I then opened the my_Random_Byte_Source_impl.cc file and added:
>
> #include <gnuradio/random.h>
>
> /*
>      * The private constructor
>      */
>     my_Random_Byte_Source_impl::my_Random_Byte_Source_impl()
>       : gr::sync_block("my_Random_Byte_Source",
>               gr::io_signature::make(0, 0, 0),
>               gr::io_signature::make(1, 1, sizeof(byte)))
>     {}
>
>
>
> unsigned byte
>     my_Random_Byte_Source_impl::get_bytes(const byte &sample)
>     {
>     return gr::random::random(0,0,4)
>     }
>
>
>
>   int
>     my_Random_Byte_Source_impl::work(int noutput_items,
>         gr_vector_const_void_star &input_items,
>         gr_vector_void_star &output_items)
>     {
>       byte *out = (byte *) output_items[0];
>
>       for(int i = 0; i < noutput_items; i++)
>       {
>             out[i] = get_bytes(i)
>       }
>
>       // Tell runtime system how many output items we produced.
>       return noutput_items;
>     }
>
>
>
> Then in the yml file I changed it up to be:
>
>
>
> id: Random_my_Random_Byte_Source
> label: my_Random_Byte_Source
> category: '[Random]'
>
> templates:
>   imports: import Random
>   make: Random.my_Random_Byte_Source()
>
> outputs:
> - label: out
>   dtype: byte
>
>
> #  'file_format' specifies the version of the GRC yml format used in the
> file
> #  and should usually not be changed.
> file_format: 1
>
>
>
> Now, I created the build directory and used cmake
> -DCMAKE_INSTALL_PREFIX=/home/mariom/prefix-3.8/ .. and it was able to
> complete this but it failed the make install. Here is the error:
>
>
>
> /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc: In constructor
> ‘gr::Random::my_Random_Byte_Source_impl::my_Random_Byte_Source_impl()’:
> /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:46:51: error:
> ‘byte’ was not declared in this scope
>    46 |               gr::io_signature::make(1, 1, sizeof(byte)))
>       |                                                   ^~~~
> /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc: At global scope:
> /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:57:5: error:
> expected initializer before ‘my_Random_Byte_Source_impl’
>    57 |     my_Random_Byte_Source_impl::get_bytes(const byte &sample)
>       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc: In member
> function ‘virtual int gr::Random::my_Random_Byte_Source_impl::work(int,
> gr_vector_const_void_star&, gr_vector_void_star&)’:
> /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:67:7: error:
> ‘byte’ was not declared in this scope
>    67 |       byte *out = (byte *) output_items[0];
>       |       ^~~~
> /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:67:13: error:
> ‘out’ was not declared in this scope
>    67 |       byte *out = (byte *) output_items[0];
>       |             ^~~
> /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:67:26: error:
> expected primary-expression before ‘)’ token
>    67 |       byte *out = (byte *) output_items[0];
>       |                          ^
> /home/mariom/gr-Random/lib/my_Random_Byte_Source_impl.cc:71:24: error:
> ‘get_bytes’ was not declared in this scope
>    71 |               out[i] = get_bytes(i)
>       |                        ^~~~~~~~~
> make[2]: *** [lib/CMakeFiles/gnuradio-Random.dir/build.make:63:
> lib/CMakeFiles/gnuradio-Random.dir/my_Random_Byte_Source_impl.cc.o] Error 1
> make[1]: *** [CMakeFiles/Makefile2:301:
> lib/CMakeFiles/gnuradio-Random.dir/all] Error 2
> make: *** [Makefile:141: all] Error 2
>
>
>
> So, I know it doesn't like byte but I'm not sure why. I know when I did
> the tutorial I did gr_complex and I thought gr_byte would work but it did
> not so I tried the byte by itself but it still did not work. So, I imagine
> that the problem is there but is there anything I did wrong? How can I fix
> this? Please and thank you for your help everyone.
>
>
>
> P.S. I am using ubuntu 20.04, gnuradio 3.8.4.0, and I installed it using
> pybombs which is why I used cmake
> -DCMAKE_INTSALL_PREFIX=/home/mariom/prefix-3.8/ ..
> CONFIDENTIALITY NOTICE - SNC EMAIL: This email and any attachments are
> confidential, may contain proprietary, protected, or export controlled
> information, and are intended for the use of the intended recipients only.
> Any review, reliance, distribution, disclosure, or forwarding of this email
> and/or attachments outside of Sierra Nevada Corporation (SNC) without
> express written approval of the sender, except to the extent required to
> further properly approved SNC business purposes, is strictly prohibited. If
> you are not the intended recipient of this email, please notify the sender
> immediately, and delete all copies without reading, printing, or saving in
> any manner. --- Thank You.
>

Reply via email to