# Casting an input value using block() function

**URL:** <https://www.ruby-forum.com/t/casting-an-input-value-using-block-function/224243>\
**Category:** GNU Radio\
**Created:** [November 5, 2012, 1:13am UTC](https://www.ruby-forum.com/t/casting-an-input-value-using-block-function/224243 "2012-11-05T01:13:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [November 5, 2012, 1:13am UTC](https://www.ruby-forum.com/t/casting-an-input-value-using-block-function/224243/1 "2012-11-05T01:13:26Z")

</div>

Hi,

My question is related to the work function using block() as provided in  
GRExtras. I have a block that input a gr\_complex value and output a  
gr\_complex value. I’m trying to cast the input and output, in order to  
use  
them in my work function, what I have is:

int work(  
const InputItems &input\_items,  
const OutputItems &output\_items  
){

```
  std::complex<float> * in = input_items[0].cast<std::complex<float>

```

\*\>();  
std::complex \* out =  
output\_items[0].cast\<std::complex  
\*\>();

```
 //Processing here

} //End of work function

```

I can cast the output without problem, but I cannot do it for the input.  
I  
got the following error:

/home/project/grextras/include/gnuradio/block.h: In member function T  
gnuradio::Buffer::cast() const [with T = std::complex_,  
PtrType = const void_]:  
/home/project/grextras/lib/s\_asrp\_st2up\_insertcp.cc:76:77:  
instantiated  
from here  
/home/project/grextras/include/gnuradio/block.h:43:47: error:  
reinterpret\_cast from type const void\* to type std::complex\*  
casts away qualifiers

So, I checked into the block.h I have the following:

typedef std::vector\<Buffer\<const void \*\> \> InputItems;  
typedef std::vector\<Buffer\<void \*\> \> OutputItems;

Does it mean that I cannot cast my input\_items in my work function?  
If the answer is no, how can I use the input\_items in my work function?,  
because I have to receive a stream of values.

Thanks for your comments,

Regards,

Jose

---

<div class="post-metadata">

**Author:** ![Jose\_TSDiaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@Jose\_TSDiaz](https://www.ruby-forum.com/u/Jose_TSDiaz)\
**Post date:** [November 5, 2012, 1:48am UTC](https://www.ruby-forum.com/t/casting-an-input-value-using-block-function/224243/2 "2012-11-05T01:48:34Z")

</div>

Hi,

In order to add more information, I found some information here:  
[http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Fkeyword\_const\_cast.htm](http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Fkeyword_const_cast.htm)

As I understand, the issue is with this line in block. h

typedef std::vector\<Buffer\<const void \*\> \> InputItems;

Because it is casting using const, rather than:

typedef std::vector\<Buffer\<void \*\> \> OutputItems;

I’m stuck in this point, because I’m not sure how to use the input\_items  
in  
my work function, if I’m not able to cast it.

Regards,

Jose

On Mon, Nov 5, 2012 at 10:42 AM, Jose T. Diaz  
\<removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Jose\_TSDiaz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@Jose\_TSDiaz](https://www.ruby-forum.com/u/Jose_TSDiaz)\
**Post date:** [November 6, 2012, 12:59am UTC](https://www.ruby-forum.com/t/casting-an-input-value-using-block-function/224243/3 "2012-11-06T00:59:48Z")

</div>

Thanks Bastian,

This fix the issue,

Regards,

Jose
