Issues with includes

hello, I am pretty new to swigs and cmake so I apologize ahead of time
this is a bit of basic question but I have been having some problems
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 and do_stuff.h

if I add the include file in along with
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

AttributeError: ‘module’ object has no attribute ‘radio_block’

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

thank you for your time


James Wagner

thanks for the suggestion, after checking some of the existing code I
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.

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
I suppose it does not really matter.

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
get a host of errors related to swigs. if it was not for that this would
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
to link the function independent of the class so there must be some way
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.

James Wagner

On Thu, Apr 9, 2015 at 10:39 AM, Martin B. [email protected]


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.