# Gr-modtool cpp generation issue

**URL:** <https://www.ruby-forum.com/t/gr-modtool-cpp-generation-issue/242007>\
**Category:** GNU Radio\
**Created:** [May 20, 2015, 3:06am UTC](https://www.ruby-forum.com/t/gr-modtool-cpp-generation-issue/242007 "2015-05-20T03:06:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [May 20, 2015, 3:06am UTC](https://www.ruby-forum.com/t/gr-modtool-cpp-generation-issue/242007/1 "2015-05-20T03:06:02Z")

</div>

I am in the process of converting some 3.6 modules to 3.7. So I am  
generating new modules then adding the code from the old modules. I have  
one module that takes a filename as a parameter so it is declared like  
this  
in this test module:

testfilename\_impl::testfilename\_impl(unsigned short printing, unsigned  
short print\_type, const char \*filename).

When I compile I get the error:

/home/sysala/BisonSAT/gr-bs/lib/testfilename\_impl.cc:35:63: error:  
invalid  
conversion from ‘char’ to ‘const char\*’ [-fpermissive]  
(new testfilename\_impl(printing, print\_type, \*filename));

The fix I found is to get rid of the \* in front of the filename in the  
above line. Here is the incorrect declaration:

```
testfilename::make(unsigned short printing, unsigned short 

```

print\_type,  
const char \*filename)  
{  
return gnuradio::get\_initial\_sptr  
(new testfilename\_impl(printing, print\_type, \*filename));  
}

Here is the corrected one:

```
testfilename::make(unsigned short printing, unsigned short 

```

print\_type,  
const char \*filename)  
{  
return gnuradio::get\_initial\_sptr  
(new testfilename\_impl(printing, print\_type, filename)); //got  
rid  
of \* here  
}

I can repeat this by just generating a simple general module with this  
const char \*filename parameter. The above declaration is generated by  
gr\_modtool. So if I move the \* to next to the char when I enter  
parameters  
in gr\_modtool add it works fine. So I am not sure if this is poor C++ or  
the gr\_modtool just slurping up the \*filename but I will point out the  
file\_sink block bundled with gnuradio declares its filename with the \*  
next  
to the parameter name: file\_sink::make(size\_t itemsize, const char  
\*filename, bool append).

I am using gnuradio verison 3.7.2.1.

## Al

====================  
Al Anderson, N0XV  
Director, IT Services  
Salish Kootenai College  
§ 406.275.4833  
© 406.214.8292  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Al\_Anderson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3e96dc/32.png) [@Al\_Anderson](https://www.ruby-forum.com/u/Al_Anderson)\
**Post date:** [May 20, 2015, 6:09pm UTC](https://www.ruby-forum.com/t/gr-modtool-cpp-generation-issue/242007/2 "2015-05-20T18:09:11Z")

</div>

On 19.05.2015 18:03, Al Anderson wrote:

> I can repeat this by just generating a simple general module with this  
> const char \*filename parameter. The above declaration is generated by  
> gr\_modtool. So if I move the \* to next to the char when I enter  
> parameters in gr\_modtool add it works fine. So I am not sure if this is  
> poor C++ or the gr\_modtool just slurping up the \*filename but I will  
> point out the file\_sink block bundled with gnuradio declares its  
> filename with the \* next to the parameter

Most likely modtool is slurping the \*. We rarely have pointers as such  
(a better way in this case would anyway be a const std::string &), and  
when we use references, the & needs to go away. Maybe that &-removal is  
also removing the \*.

M

---

<div class="post-metadata">

**Author:** ![Al\_Anderson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3e96dc/32.png) [@Al\_Anderson](https://www.ruby-forum.com/u/Al_Anderson)\
**Post date:** [May 20, 2015, 6:16pm UTC](https://www.ruby-forum.com/t/gr-modtool-cpp-generation-issue/242007/3 "2015-05-20T18:16:47Z")

</div>

On 20.05.2015 09:07, Martin B. wrote:

> when we use references, the & needs to go away. Maybe that &-removal is  
> also removing the \*.

Erm, I got things mixed up here. What I meant was, modtool slurps &'s  
correctly, and should also slurp \*'s, which it currently doesn’t. Easy  
fix, though. I’ll put up a PR ASAP.

M
