Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-07-17 20:26:11


Hi,

Compaq C++ for Tru64 seems to have found a problem with the iostreams library
that none of the other compilers caught.

zlib and libbz2 allow the programmer to customize memory management by
specifying a pair of function pointers for allocation and deallocation. I wanted
to provide an adaption layer so that users could specify standard library
compatible allocators instead. To do this, I defined a class template
parameterized by an allocator and having two static member functions with the
same signature as the allocation and deallocation functions, and then passed
pointers to these static member functions to the zlib and libbz2 API.

Unfortunately, when compiled as C++, the zlib and libbz2 headers declare the
allocation and deallocation function pointer types as extern "C", and Compaq
(correctly, I think) refuses to let me assign pointers to static member
functions to variables whose type are declared extern "C".

Is there some way to get around this?

If not, what should I do?

1. expose the C-language customization interface (yuck)
2. remove the customization interface
3. remove the customization interface only for platforms where it doesn't work
4. Use some more elaborate trick, such as supplying extern "C" allocation
functions which operate by delegating to pointers stored in a table.

I like 2.

Jonathan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk