Using g++ version 4.8.4 I get an error:
error: invalid conversion from ‘const SSL_METHOD* ()() {aka const ssl_method_st ()()}’ to ‘MethodFuncPtr {aka ssl_method_st (*)()}’ [-fpermissive]
I can compile with -fpermissive, but what is a fix? I've seen solutions for this type of error, but none for when the return type is const (even though it's explicitly a const return value).
A snippet from ssl.h (C header):
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ssl_method_st {
int version;
int (*ssl_new) (int *s);
void (*ssl_clear) (int *s);
} SSL_METHOD;
const SSL_METHOD *TLSv1_method(void);
#ifdef __cplusplus
}
endif
C++ header:
#include <ssl.h>
extern "C" {
typedef SSL_METHOD*(*MethodFuncPtr)(void);
}
class Method
{
public:
Method(SSL_METHOD *method);
static const MethodFuncPtr TLSv1;
private:
SSL_METHOD *m_method;
};
C++ source:
Method::Method(SSL_METHOD* method)
: m_method(method)
{ }
const MethodFuncPtr Method::TLSv1 = TLSv1_method;
Aucun commentaire:
Enregistrer un commentaire