[SciPy-dev] Weave, numpy, external libraries and conflicting typedefs
Prabhu Ramachandran
prabhu_r at users.sf.net
Fri Jul 7 14:33:54 CDT 2006
>>>>> "Travis" == Travis Oliphant <oliphant.travis at ieee.org> writes:
>> Earlier, with Numeric, arrayobject.h did not define typedefs
>> for the Int32 and so on. However, numpy defines several
>> typedefs that conflict with the typedefs in Ygl.
Travis> You need to #define PY_ARRAY_TYPES_PREFIX ygl_
Travis> or something like that before including arrayobject.h
Thanks! I tried to do this but there are more problems.
arrayobject.h defines MAX/MIN macros. My own code defines these as
generic functions. I can work around those easily, and after I did
that I ended up with compilation errors below (where foo.cpp is the
weave generated code):
foo.cpp: In member function 'void numpy_type_handler::conversion_numpy_check_type(PyArrayObject*, int, const char*)':
foo.cpp:494: error: expected primary-expression before ')' token
foo.cpp:494: error: 'Bool' was not declared in this scope
foo.cpp:494: error: expected primary-expression before 'int'
foo.cpp:494: error: expected primary-expression before 'int'
foo.cpp:494: error: expected `)' before 'PyArray_API'
[...]
The code in question is:
482 void conversion_numpy_check_type(PyArrayObject* arr_obj, int numeric_type,
483 const char* name)
484 {
485 // Make sure input has correct numeric type.
486 int arr_type = arr_obj->descr->type_num;
487 if (PyTypeNum_ISEXTENDED(numeric_type))
488 {
489 char msg[80];
490 sprintf(msg, "Conversion Error: extended types not supported for variable '%s'",
491 name);
492 throw_error(PyExc_TypeError, msg);
493 }
494 if (!PyArray_EquivTypenums(arr_type, numeric_type))
495 {
If I don't "#define PY_ARRAY_TYPES_PREFIX ygl_" I don't get these
errors.
I see the problem. PyArray_EquivTypenums ultimately returns a Bool
(defined in __multiarray_api.h) and Bool is undef'd when
PY_ARRAY_TYPES_PREFIX is set. If I comment the undef Bool this
compiles fine.
Is there anything that can be done or should I just try and work
around the problem in my code?
Also, would you consider changing the MAX/MIN macro names?
Thanks again!
regards,
prabhu
More information about the Scipy-dev
mailing list