1 (edited by move 2019-05-02 11:08:13)

Topic: Feature detection in application -- which header to include?

Hi all,

I'm working on an HTTPS client using wolfSSL. I want to use HAVE_* or NO_* flags to make the client work with different configurations. I see there are ''wolfssl/options.h', 'wolfssl/wolfcrypt/settings.h', and config.h produced by configure. Which should I use to detect features? client.c includes neither...

Fan

Share

Re: Feature detection in application -- which header to include?

Hi move,

The two header files you're referring to aren't really there for detecting features, they're there to tell the wolfSSL library which features it should build with. You can search the files to see if features are being used or not though. Depending on the configuration of the wolfSSL library, it can use different settings files under different names.

The options.h file is generated and used when the wolfSSL library is configured and built with automake tools and the configure script. The settings.h file is used for setting OS-specific options that the wolfSSL library will use. Every application using the wolfSSL library should be including the file wolfssl/wolfcrypt/settings.h before including any other wolfSSL headers, and I see that it is being included in examples/client/client.c around line 27. Is this the client you're referring to?

If you had any other questions or information that was needed, please feel free to let me know.

Share

Re: Feature detection in application -- which header to include?

alex.abrahamson wrote:

Every application using the wolfSSL library should be including the file wolfssl/wolfcrypt/settings.h before including any other wolfSSL headers, and I see that it is being included in examples/client/client.c around line 27. Is this the client you're referring to?

Yes, you're right. I missed that.

Suppose I built the library using the configure script, and now want to compile an application, I see one way to detect feature is to define HAVE_CONFIG_H and include the generated config.h, like in the example client:

#ifdef HAVE_CONFIG_H
        #include <config.h>
#endif

Is that a reasonable approach?

Share

Re: Feature detection in application -- which header to include?

Hi move,

If you want to detect features enabled by the configure script, you'll want to use the options file that was mentioned earlier (wolfssl/options.h). The config.h file is used with the MDK builds and wouldn't work very well with your application.

Share