# Issues with includes

**URL:** <https://www.ruby-forum.com/t/issues-with-includes/241487>\
**Category:** GNU Radio\
**Created:** [April 9, 2015, 5:07pm UTC](https://www.ruby-forum.com/t/issues-with-includes/241487 "2015-04-09T17:07:14Z")\
**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:** [April 9, 2015, 5:07pm UTC](https://www.ruby-forum.com/t/issues-with-includes/241487/1 "2015-04-09T17:07:14Z")

</div>

hello, I am pretty new to swigs and cmake so I apologize ahead of time  
if  
this is a bit of basic question but I have been having some problems  
geting  
c++ blocks to run if I add an include to my own generated code.

for example I might have a block radio\_block and a function do\_stuff()  
contain in do\_stuff.cc and do\_stuff.h

if I add the include file in module\_name\_radio\_block\_impl.cc along with  
the  
other includes and then places a call to do\_stuff() in general work the  
block will compile just fine but when I run the block i’ll get an error  
message

AttributeError: ‘module’ object has no attribute ‘radio\_block’

I have no problem creating an non-block and implementing objects there  
but  
this precludes me adding a simple function without creating a new object  
or  
adding new methods to the existing objects.

thank you for your time

sincerely,

James Wagner

---

<div class="post-metadata">

**Author:** ![James\_Wagner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e7dd6/32.png) [@James\_Wagner](https://www.ruby-forum.com/u/James_Wagner)\
**Post date:** [April 9, 2015, 10:12pm UTC](https://www.ruby-forum.com/t/issues-with-includes/241487/2 "2015-04-09T22:12:57Z")

</div>

thanks for the suggestion, after checking some of the existing code I  
at  
least have a bit better idea of where things stand. I don’t know the  
details yet but I believe the issue is somehow connected to linking and  
swigs. In any case I found two possible solutions.

1. 

include the definition rather than a declaration

this bypasses the linker altogether and an instance of this can be seen  
in expj.h

unfortunately unless I am thinking of this wrong this can contribute to  
code bloat since you will have a copy of the function in each file which  
uses the header. in the case of expj the function is meant to be inline  
so  
I suppose it does not really matter.

1. 

place the function definition in a non-block.

this works even as a non class member function but only if I leave the  
generated class in the header and source. If I remove the class entirely  
I  
get a host of errors related to swigs. if it was not for that this would  
be  
a straightforward solution but I am not sure how I feel keeping a random  
empty class around just to get my function to link. the program is  
managing  
to link the function independent of the class so there must be some way  
to  
do it but I am not quite sure how yet.

well thanks for the input so far and sorry if that was a bit wordy.

Sincerely,  
James Wagner

On Thu, Apr 9, 2015 at 10:39 AM, Martin B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![James\_Wagner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8e7dd6/32.png) [@James\_Wagner](https://www.ruby-forum.com/u/James_Wagner)\
**Post date:** [April 9, 2015, 7:40pm UTC](https://www.ruby-forum.com/t/issues-with-includes/241487/3 "2015-04-09T19:40:49Z")

</div>

James,

look at examples for non-block stuff, such as:

- Constellation object
- Packet Header formatters
- OFDM Equalizers

SWIG is considered black magic by most of us, so using working examples  
is the way to go.

Cheers,  
M
