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

Nikos Mavrogiannopoulos nmav at gnutls.org
Wed Jul 20 13:28:42 CEST 2016


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

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

> Personally, I don't see the point in using enums for flags in C. AFAIK, gcc
> doesn't check types for enums at all. Using any value for an enum variable or
> function parameter is allowed (no warning). Do I miss something here ?

The reason of this change was that the current documentation
generation works well with enumerations but not definitions and I
wanted to include the gnutls_init flags to the generated
documentation.

regards,
Nikos



More information about the Gnutls-devel mailing list