[C++-sig] Avoiding duplicate registration of Py++ generatedarray code?

Roman Yakovenko roman.yakovenko at gmail.com
Tue Jan 23 09:18:54 CET 2007

On 1/22/07, Haridev, Meghana <mharidev at qualcomm.com> wrote:
> Hi Roman,
> I agree that your suggestions would help in getting rid of the warnings
> for duplicate registration, but here is what I am really concerned
> about:
> When we do this:
> >> import Boost_Lib1
> >> import Boost_Lib2
> >> RuntimeWarning: to-Python converter for
> pyplusplus::containers::static_sized::array_1_t<unsigned char, 128>
> already registered; second conversion method ignored.
> The to-Python converter that will be used for
> pyplusplus::containers::static_sized::array_1_t<unsigned char, 128> by
> Class C (of library Boost.Lib2.so) is actually registered(by Class A) in
> ANOTHER library (Boost_Lib1.so) .
> 1) Are there any problems that could arise from using a to-Python
> converter that resides in ANOTHER shared library? Ideally, I would like
> to use a to-Python converter that is registered within the SAME shared
> library.

Search this list, the issue was discussed recently.

> 2) Regarding using a string as another template argument, it is possible
> to do so. Here's some example code:
> extern char const s[] = "hello";
> template <char const* name>
> class MyClass {
> ...
> };
> MyClass<s> x;
> Here, the global character array s is initialized by "hello" so that s
> is an object with external linkage.
> This way using another template argument for the array classes (such as
> a unique string: template< class TItemType, long unsigned int size, char
> const* name >) we can ensure that to-Python converters for each array
> will be registered within the SAME shared library. What do you think?

I think this is a hack. The hack does not work on std classes. I think
this is the wrong
way to go, but I could be wrong.

Roman Yakovenko
C++ Python language binding

More information about the Cplusplus-sig mailing list