Subject: OpenSSL is not compatible with C++?
To: None <tech-userlevel@netbsd.org>
From: Ian Zagorskih <ianzag@megasignal.com>
List: tech-userlevel
Date: 09/06/2005 19:03:15
OpenSSL from NetBSD v3.99.7 base. Simple test code:
---test.c---
#include <openssl/ssl.h>
void foo() {
PEM_write_bio_SSL_SESSION(0, 0);
}
---test.c---
When i compile it as C code all goes just fine:
$ cc -c -Wall test.c
But when i compile it as C++ code invalid convertion error happens:
$ c++ -c -Wall test.c
test.c: In function `void foo()':
test.c:5: error: invalid conversion from `int (*)()' to `int (*)(...)'
Looking at PEM_write_bio_SSL_SESSION() definition:
---pem.h---
#define PEM_write_bio_SSL_SESSION(bp,x) \
PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \
PEM_STRING_SSL_SESSION,bp, (char *)x, NULL,NULL,0,NULL,NULL)
........
int PEM_ASN1_write_bio(int (*i2d)(),const char *name,BIO *bp,char *x,
const EVP_CIPHER *enc,unsigned char *kstr,int klen,
pem_password_cb *cb, void *u);
---pem.h---
AFAIU declaration of PEM_ASN1_write_bio() i.e. its first parameter is correct
from C point of view but is wrong for C++ and there are tons of such examples
which are fine for C but wrong for C++. I'm trying to build some project
which uses C++ and depends on OpenSSL and I got such compile errors on every
step. Any ideas what to do?
// wbr