Volker, The library in question does need me to pass a C array. I am currently overcoming the problem by using malloc but fter the library call I get a corrupt pointer back, that I cannot free. Hence I am trying to see how would it work with new/delete.
Best, Jernej On Friday, 21 March 2014 18:40:50 UTC+1, Volker Braun wrote: > > You aren't even trying to construct a C++ objects. Unless your C++ library > expects C arrays as inputs, I would recommend that you forget about them. > Use STL vectors as containers. See src/sage/tests/stl_vector.pyx for an > example. > > > > > > > On Friday, March 21, 2014 7:41:08 AM UTC-4, Jernej Azarija wrote: >> >> Hello, >> >> I would like to write a Cython wrapper for a C++ library. Since the >> library in question requires me to pass C++ objects, I am trying to figure >> out how to do it in Cython. I am having some trouble using the construct >> new. >> >> The minimal example of the problem being resembled by the following >> program: >> >> ========= min.pyx ========== >> from libcpp cimport bool as bool >> >> def foo(G): >> cpdef bool **adj >> adj = new bool*[10] >> >> ========= min.pyx ========== >> >> ========================== >> When trying to load the example (Ioad min.pyx) I get the following error: >> >> def foo(G): >> cpdef bool **adj >> adj = new bool*[10] >> ^ >> ------------------------------------------------------------ >> >> _home_azi_7630814_mcqd_min_pyx_0.pyx:13:23: Expected ')', found 'NEWLINE' >> =========================== >> >> What exactly is going on? The same thing happens if I want to create some >> other C++ object. >> >> Best, >> >> Jernej >> >> -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.