[C++-sig] [boost.python] char arrays in structs

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Tue Jul 5 11:14:30 CEST 2005

--- David Abrahams <dave at boost-consulting.com> wrote:
> The size information is not lost; the parameter type is 
>   char const(&)[4]

Interesting. I don't think I would have figured this out myself. Thanks!

> > Why would I want to use "boost::array<char, 4>" instead of "typedef
> > char[4]"?
> I don't know; I never suggested that idea.  Wasn't that your
> suggestion?

Yes, because I didn't know about the char const(&)[4] trick.

I played around a bit with char const(&)[N] conversions, starting
with Markus' converter. I got both to_python and from_python
conversions to work under Linux and Tru64 Unix. Here is the
code if anyone is interested:


For the records: I encountered two problems:

- Under Redhat WS 3 (gcc 3.2.3) the char[4] converters
  work with -O0 -g, but not with -O3 -ffast-math.
  char[3] and char[5] work both with and without optimization.

- It compiles but doesn't work under Windows. I don't know why; no
  time to investigate right now. At the moment I just wanted to find
  out if it works in principle.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the Cplusplus-sig mailing list