# Trouble with PMTs

**URL:** <https://www.ruby-forum.com/t/trouble-with-pmts/233872>\
**Category:** GNU Radio\
**Created:** [January 19, 2015, 12:29am UTC](https://www.ruby-forum.com/t/trouble-with-pmts/233872 "2015-01-19T00:29:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [January 19, 2015, 12:29am UTC](https://www.ruby-forum.com/t/trouble-with-pmts/233872/1 "2015-01-19T00:29:53Z")

</div>

I’m updating older code from using the old streaming messaging to the  
new  
and improved message passing and PMTs. However I am getting an error  
compiling.

Here is the code snippet:

void energy\_detector\_sink\_f\_impl::send\_to\_message\_p(float \*out, int  
items\_consumed) {  
pmt::pmt\_t msg = pmt::cons(  
const pmt::pmt\_t out,  
const pmt::pmt\_t  
sizeof(float)\*items\_consumed  
);  
message\_port\_pub(d\_outfreq, msg);  
}

and the error:

/home/fox/git\_repos/custom\_modules/gr-specsense/lib/energy\_detector\_sink\_f\_impl.cc:  
In member function ‘void  
gr::specsense::energy\_detector\_sink\_f\_impl::send\_to\_message\_p(float\*,  
int)’:  
/home/fox/git\_repos/custom\_modules/gr-specsense/lib/energy\_detector\_sink\_f\_impl.cc:147:  
error: expected primary-expression before ‘const’  
/home/fox/git\_repos/custom\_modules/gr-specsense/lib/energy\_detector\_sink\_f\_impl.cc:148:  
error: expected primary-expression before ‘const’  
make[2]: \*\*\*  
[lib/CMakeFiles/gnuradio-specsense.dir/energy\_detector\_sink\_f\_impl.cc.o]  
Error 1  
make[1]: \*\*\* [lib/CMakeFiles/gnuradio-specsense.dir/all] Error 2  
make: \*\*\* [all] Error 2

By no means do I consider myself an expert in C++ so I am not really  
sure  
if this is a PMT problem or not but because PMTs are involved it makes  
troubleshooting via Google a little trickier.

Jonathan

---

<div class="post-metadata">

**Author:** ![jfaulkenberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c2a13f/32.png) [@jfaulkenberry](https://www.ruby-forum.com/u/jfaulkenberry)\
**Post date:** [January 19, 2015, 8:14am UTC](https://www.ruby-forum.com/t/trouble-with-pmts/233872/2 "2015-01-19T08:14:12Z")

</div>

On 01/19/2015 12:28 AM, Jonathan F. wrote:

> 

/home/fox/git\_repos/custom\_modules/gr-specsense/lib/energy\_detector\_sink\_f\_impl.cc:

> In member function void  
> gr::specsense::energy\_detector\_sink\_f\_impl::send\_to\_message\_p(float\*, int):

/home/fox/git\_repos/custom\_modules/gr-specsense/lib/energy\_detector\_sink\_f\_impl.cc:147:

> error: expected primary-expression before const

/home/fox/git\_repos/custom\_modules/gr-specsense/lib/energy\_detector\_sink\_f\_impl.cc:148:

> error: expected primary-expression before const

The error code is telling you what you need to know; your C++ is  
invalid. You can’t declare variables inside the call to cons(). Use the  
converter functions to convert ‘out’ to a PMT (same with the second PMT)  
or use the constructor notation and skip the ‘const’.

This is unrelated to PMT or even GNU Radio. I’m sure googling for the  
gcc error message would have given you at least some response.

Cheers,  
M

---

<div class="post-metadata">

**Author:** ![jfaulkenberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c2a13f/32.png) [@jfaulkenberry](https://www.ruby-forum.com/u/jfaulkenberry)\
**Post date:** [January 19, 2015, 4:33pm UTC](https://www.ruby-forum.com/t/trouble-with-pmts/233872/3 "2015-01-19T16:33:02Z")

</div>

Thanks for the help.

The first thing I did was search the compiler error but wasn’t  
successful  
in finding a well written answer such as yours.

On Mon, Jan 19, 2015 at 2:12 AM, Martin B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
