[gnutls-devel] Moving defines (3.4) to enum (3.5.) in header files needs discussion...

Tim Ruehsen tim.ruehsen at gmx.de
Wed Jul 20 13:41:51 CEST 2016


On Wednesday, July 20, 2016 1:28:42 PM CEST Nikos Mavrogiannopoulos wrote:
> On Wed, Jul 20, 2016 at 12:30 PM, Tim Ruehsen <tim.ruehsen at gmx.de> wrote:
> > Hi Nikos,
> > I just realized that you turned several defines into enums with GnuTLS
> > 3.5.x. This simply breaks existing code (e.g. wget2) and took me a while
> > to find out.
> > 
> > Example:
> > #ifdef GNUTLS_NONBLOCK
> > 
> >                 gnutls_init(&session, GNUTLS_CLIENT | GNUTLS_NONBLOCK);
> > 
> > #else
> > 
> >         // very old gnutls version, likely to not work.
> >         gnutls_init(&session, GNUTLS_CLIENT);
> > 
> > #endif
> 
> You're right, that's an unintended side effect. A solution for gnutls'
> code is to redefine these as in:
> https://gitlab.com/gnutls/gnutls/merge_requests/25

Yes thanks, that should do it :-) And if it still works for the docs, it seems 
to be perfect.

> For your code, you may want to use instead:
> #if GNUTLS_VERSION_NUMBER > 0x030000
> which is part of the documented API.

Right. I just don't know when GNUTLS_NONBLOCK has been invented, so I do
#if GNUTLS_VERSION_NUMBER >= 0x030500
// 3.5+ code
#elif defined(GNUTLS_NONBLOCK)
// pre 3.5 code
#else
// legacy code
#endif

Regards, Tim
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: </pipermail/attachments/20160720/1a6a4634/attachment.sig>


More information about the Gnutls-devel mailing list