[SciPy-dev] patch: allow arrayobject.h to compile in c++ compiler

David M. Cooke cookedm at physics.mcmaster.ca
Wed Nov 23 17:01:03 CST 2005


Andrew Straw <strawman at astraw.com> writes:

> David M. Cooke wrote:
>
>>On Nov 22, 2005, at 11:49 , Andrew Straw wrote:
>>
>>  
>>
>>>But would it make sense to rename Bool to ScipyBool or something less likely to
>>>defined in other source?
>>>    
>>>
>>
>>This is the reason for PY_ARRAY_TYPES_PREFIX. If you do this:
>>
>>#define PY_ARRAY_TYPES_PREFIX Scipy
>>#include "scipy/arrayobject.h"
>>
>>then all the types that scipy defines will have Scipy prefixed (so  
>>ScipyBool, Scipybyte, Scipyuint, etc.).
>>  
>>
>
> I haven't jumped into the source on this, but your suggestion doesn't
> entirely seem to work. If I do as you suggest and include the "#define
> PY_ARRAY_TYPES_PREFIX Scipy" before including arrayobject.h, I don't get
> the redefinition of type int error (and thus my extension builds), but I
> get the following warning:
>
> building 'fsee.FlySimWrap' extension
> gcc options: '-pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall
> -Wstrict-prototypes -fPIC'
> compile options: '-Isrc
> -I/home/astraw/py24-amd64/lib/python2.4/site-packages/scipy/base/include
> -I/usr/include/python2.4 -c'
> gcc: src/CXX/cxxextensions.c
> gcc: src/FlySim/skybox.cpp
> gcc: src/FlySim/FlySimWrap.cpp
> In file included from src/FlySim/FlySimWrap.cpp:16:
> /home/astraw/py24-amd64/lib/python2.4/site-packages/scipy/base/include/scipy/arrayobject.h:25:1:
> warning: "Bool" redefined
> In file included from /usr/include/Producer/Types:37,
>                  from /usr/include/Producer/Math:18,
>                  from /usr/include/Producer/Camera:24,
>                  from src/FlySim/FlySim.hpp:10,
>                  from src/FlySim/FlySimWrap.hpp:9,
>                  from src/FlySim/FlySimWrap.cpp:1:
> /usr/include/X11/Xlib.h:96:1: warning: this is the location of the
> previous definition

What's the order of the includes? If you include arrayobject.h before
the other includes, it should work.

In general, this would be a pain to fix. arrayobject.h would have to
save the old definition and restore it.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke                      http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca




More information about the Scipy-dev mailing list