Re: Build failed in Hudson: 3.HEAD-i386-opensolaris-SunStudioCc #502

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Sat, 04 Dec 2010 17:36:09 -0700

On 12/04/2010 08:38 AM, Henrik Nordström wrote:
> fre 2010-12-03 klockan 19:11 +0200 skrev Tsantilas Christos:

>> "../../../src/ssl/gadgets.h", line 38: Error, temargnoval: Template
>> parameter DeAllocator requires an expression of type void(*)(x509_st*).

>> The only way I found to solve the above is to define C++ wrappers
>> functions for X509_free, EVP_PKEY_free, BIG_NUM_free etc (~ 10 wrapper
>> functions)

> extern "C" in the DeAllocator declaration should be sufficient, maybe
> "hidden" in an typedef for clarity.

extern "C" is not ideal because it would limit TidyPointer to C
de-allocators. Besides, it is illegal in template parameter declarations:

    error: storage class specifiers invalid in parameter declarations

I think our options are:

   (a) wrap X509_free and friends into their C++ versions. It may be
possible to do that with a single macro if inline functions can have
storage class specifiers:

     #define CtoCpp1(function, argument) \
         extern "C++" inline void function ## _cpp(argument a) { \
             function(a); \
         }

     CtoCpp1(X509_free, X509*);

     typedef TidyPointer<X509, X509_free_cpp> X509_Pointer;

   (b) Change TidyPointer to use a class instead of a function pointer
as the second parameter (this is what STL does; see std::find). However,
this would require specifying deallocators when declaring variables
rather than at typedef time so it would lead to uglier code or more
#defines and similar hacks.

Sounds like (a) is the way to go. Any better ideas?

BTW, Christos, you do not need the deAllocator member. Just use the
template parameter.

HTH,

Alex.
Received on Sun Dec 05 2010 - 00:36:33 MST

This archive was generated by hypermail 2.2.0 : Mon Dec 06 2010 - 12:00:04 MST