How to expose std::vector as a Python list using SWIG?

That's what I tried and I get a bunch of warnings when compiling with g++. Any ideas? – Marcos Lara Nov 10 '08 at 19:54 What version of g++ are you using?

I'm using 4.1.2 and I don't get any warnings, even with -Wall. I don't remember any warnings back when I was using 3.3 or so either. Note the extra "" in this post that's missing from the original post.

– Mr Fooz Nov 11 '08 at 17:41 The was there, but it wasn't showing. Fixed it! – Marcos Lara Nov 12 '08 at 9:25 I'm using g++ 4.2.4 and trying to build with -Wall -Werror -ansi -pedantic.

I just tried building it with just -Wall and still get the warnings. – Marcos Lara Nov 12 '08 at 9:27 This might be a new 4.2-ism. There have been some big changes under the hood with gcc 4.2.Could you post the generated line of code that's creating this warning?

– Mr Fooz Nov 12 '08 at 14:02.

These are the lines before the offending line in the same function: SWIGINTERN PyObject *_wrap_IntVector_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; std::vector *arg1 = (std::vector *) 0 ; std::vector::iterator arg2 ; std::vector::iterator result; void *argp1 = 0 ; int res1 = 0 ; swig::PySwigIterator *iter2 = 0 ; int res2 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if (!PyArg_ParseTuple(args,(char *)"OO:IntVector_erase",&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_erase" "', argument " "1"" of type '" "std::vector *""'"); } arg1 = reinterpret_cast * >(argp1); And this is the offending line: res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0); More code follows that. The warning generated when compiling with g++ 4.2.4 is: swig_iss_wrap. Cxx: In function ‘PyObject* _wrap_IntVector_erase__SWIG_0(PyObject*, PyObject*)’: swig_iss_wrap.

Cxx:5885: warning: dereferencing type-punned pointer will break strict-aliasing rules.

I don't have much experience with Swig, but are you #including your C++ header file in your . I file? Try one (or both) of %include "myvector.

H" %{ # include "myvector. H" %}.

I don't have much experience with Swig, but are you #including your C++ header file in your . I file? Try one (or both) of.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions