Subject: Re: OpenSSL is not compatible with C++?
To: Ian Zagorskih <ianzag@megasignal.com>
From: Thomas Dickey <dickey@radix.net>
List: tech-userlevel
Date: 09/06/2005 08:58:21
--PEIAKu/WMn1b1Hv9
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:
>=20
> OpenSSL from NetBSD v3.99.7 base. Simple test code:
>=20
> ---test.c---
> #include <openssl/ssl.h>
>=20
> void foo() {
>         PEM_write_bio_SSL_SESSION(0, 0);
> }
> ---test.c---
>=20
> 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=
 test.c

> 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=
rect=20
> from C point of view but is wrong for C++ and there are tons of such exam=
ples=20
> which are fine for C but wrong for C++. I'm trying to build some project=
=20

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

--=20
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (SunOS)
Comment: For info see http://www.gnupg.org

iD8DBQFDHZJrtIqByHxlDocRAqGLAJ4zVqPSvwbWUCMwF3wHHhB3E/QKjwCfUuu3
H0VgcwFRsujOV0zDEeV+tsA=
=sGrn
-----END PGP SIGNATURE-----

--PEIAKu/WMn1b1Hv9--