[gnutls-devel] GnuTLS | gnutlsxx: become header-only library (!1622)

Read-only notification of GnuTLS library development activities gnutls-devel at lists.gnutls.org
Sat Aug 6 19:21:39 CEST 2022

Nikolaos Chatzikonstantinou commented on a discussion: https://gitlab.com/gnutls/gnutls/-/merge_requests/1622#note_1053063594

I can come up with two solutions, but first let me summarize the current situation:

In the first commit, I included `<config.h>` in the header. This is wrong. In the second commit, I removed `<config.h>` from the header, and placed it in the `gnutlsx.cpp` file instead. But now the header has no support for extra features configured during the build process, even if the C library supports them.

The two solutions: One is a generated header that includes only the definitions of enabled features, that is included by `<gnutlsxx.h>`. This again ties the header to the C library, since a differently-built C library (say, less features) may be missing symbols. The other option is to add functions in the C++ header-only library, such as:

    bool have_X_feature(void) {
        return true;
        return false;

The user would check that `have_X_feature()` is true before using said feature. Note that `have_X_feature()` is a function in the C library. This decouples the C++ header from the C library and allows the user to have a choice of which C library to link to, using the same C++ header.

Yet another behavior of the C++ wrapper would be to throw an exception if the feature is missing in an invoked function. Again the underlying C library function as above would be required. I'm leaning towards providing a C function that lets the user know at runtime whether a feature was enabled or disabled, but I wanted to ask for your opinion.

Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/-/merge_requests/1622#note_1053063594
You're receiving this email because of your account on gitlab.com.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20220806/f140bbc0/attachment.html>

More information about the Gnutls-devel mailing list