Subject: OpenSSL is not compatible with C++?
To: None <>
From: Ian Zagorskih <>
List: tech-userlevel
Date: 09/06/2005 19:03:15
OpenSSL from NetBSD v3.99.7 base. Simple test code:

#include <openssl/ssl.h>

void foo() {
        PEM_write_bio_SSL_SESSION(0, 0);

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:

#define PEM_write_bio_SSL_SESSION(bp,x) \
		PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \
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);

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