wrapping code uses "new" when gcc compiler is invoked.

Bug #1395108 reported by Doug
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PyBindGen
New
Undecided
Unassigned

Bug Description

I *think* this is a bug. I'm new to PyBindGen. I was following the example for wrapping a struct. Here is my .h file.

--------example.h-----
typedef struct FooStruct
{
   int a;
   double b;
} Foo;
--------

Here is my binding file, ex-binding.py
----------
import sys
sys.path.append('/g/g16/doug/python/PyBindGen-0.17.0')
import pybindgen

mod = pybindgen.Module('ex')
mod.add_include('"example.h"')
struct = mod.add_struct('Foo')
struct.add_instance_attribute('a', 'int')
struct.add_instance_attribute('b', 'double')
mod.generate(sys.stdout)
----------

Here are my compile lines:

python ex-binding.py > ex-binding.c
gcc -c -fPIC -I/usr/local/include/python2.7.3 ex-binding.c -o ex-binding.o
ex-binding.c: In function '_wrap_PyFoo__tp_init__0':
ex-binding.c:209:17: error: 'new' undeclared (first use in this function)

So, the problem is that PyBindGen is using 'new' rather than malloc, even when the compiler is gcc and there is no C++ anywhere in sight. Which is fine with me, but the docs and examples regarding wrapping structs that I read (https://pythonhosted.org/PyBindGen/tutorial.html#building-it-gcc-instructions) mentioned gcc rather a lot, and did not explicitly say I had to compile with g++ to make PyBindGen work. Just thought you should know that this tripped up a newbie. Compiling with g++ for everything does work around the problem.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.