Hi, I've been reading the <a href="http://wiki.cython.org/WrappingCPlusPlus" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">WrappingC++</a> code with pyrex/Cython. But I'm still unable to compile it; even the attached example.<br>
<br>when I run "pyrexc rectangle.pyx "<br>I get:<br><br>.../rectangle.pyx:29:27: Syntax error in C variable declaration<br>
<br>Which refers to<br><br> def __add__(Rectangle left, Rectangle right):<br><span style="font-weight: bold;"> cdef c_Rectangle c = left.thisptr.add(right.thisptr[0])</span><br> cdef Rectangle sum = Rectangle(c.x0, c.y0, c.x1, c.y1)<br>
return sum<br><br><span style="text-decoration: underline;">And in my own code i get the following</span><br><br>GOptimization.pyx:91:32: Object of type 'cGCoptimization' has no attribute 'expansionIter'<br>
<br>And the code which refers is<br>
<br><span style="font-family: courier new,monospace;">cdef extern </span><span style="color: rgb(51, 51, 255); font-family: courier new,monospace;">from</span><span style="font-family: courier new,monospace;"> </span><span style="color: rgb(51, 204, 0); font-family: courier new,monospace;">"GCoptimization.h"</span><span style="font-family: courier new,monospace;">:</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> ctypedef int PixelType</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ctypedef struct cGCoptimization </span><span style="color: rgb(51, 204, 0); font-family: courier new,monospace;">"GCoptimization"</span><span style="font-family: courier new,monospace;">:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> EnergyType expansionIter "expansion"(int max_num_iterations)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> cGCoptimization *newGCoptimization </span><span style="color: rgb(51, 204, 0); font-family: courier new,monospace;">"new GCoptimization" </span><span style="font-family: courier new,monospace;">(PixelType num_pixels,int num_labels,int dataSetup, int smoothSetup)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> void delGCOptimization </span><span style="color: rgb(51, 204, 0); font-family: courier new,monospace;">"delete" </span><span style="font-family: courier new,monospace;">(cGCoptimization *optimization) </span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">cdef </span><span style="color: rgb(51, 51, 255); font-family: courier new,monospace;">class</span><span style="font-family: courier new,monospace;"> GCoptimization:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> cdef cGCoptimization *optimization</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><span style="color: rgb(51, 51, 255); font-family: courier new,monospace;">def</span><span style="font-family: courier new,monospace;"> __new__(self, num_pixels, num_labels, dataSetup, smoothSetup):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> self.optimization = newGCoptimization(num_pixels, num_labels, dataSetup, smoothSetup)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><span style="color: rgb(51, 51, 255); font-family: courier new,monospace;">def</span><span style="font-family: courier new,monospace;"> __dealloc__(self):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> delGCOptimization(self.optimization)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def expansionIter(self,max_num_iterations):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace; font-weight: bold;"> </span><span style="color: rgb(51, 51, 255); font-family: courier new,monospace; font-weight: bold;">return</span><span style="font-family: courier new,monospace; font-weight: bold;"> self.optimization.expansionIter(max_num_iterations)</span><br style="font-weight: bold;">
<br>If u have any idea to give I would appreciate it very much, I'm kind of lost in here.<br><br>Thank you, again,<br>Warmest Regards,<br><span>Marco</span>