Subject: Re: OpenSSL is not compatible with C++?
To: Ian Zagorskih <>
From: Thomas Dickey <>
List: tech-userlevel
Date: 09/06/2005 08:58:21
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Sep 06, 2005 at 07:03:15PM +0700, Ian Zagorskih wrote:
> 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=20

for grins

gcc -c -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wconversion=

> But when i compile it as C++ code invalid convertion error happens:
> $ c++ -c -Wall test.c=20
> test.c: In function `void foo()':
> test.c:5: error: invalid conversion from `int (*)()' to `int (*)(...)'

yes - given that it's been like this for several years, apparently OpenSSL's
developers aren't interested.  The easy workaround is to write a wrapper in
C that calls the necessary function.

> AFAIU declaration of PEM_ASN1_write_bio() i.e. its first parameter is cor=
> from C point of view but is wrong for C++ and there are tons of such exam=
> which are fine for C but wrong for C++. I'm trying to build some project=

it's passable (studentware) for C, but still incorrect in C as well.

Thomas E. Dickey

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.0.6 (SunOS)
Comment: For info see