I'm troubleshooting a bit of code that requires a certain version of OpenSSL. If the version number exported by OpenSSL isn't high enough, a warning is returned, and various bits of the program are turned off.
The code looks like this:
#if OPENSSL_VERSION_NUMBER >= 0x10002000
//code here
#else
#warning "http_auth_ldap: Compiling with OpenSSL < 1.0.2, certificate verification will be unavailable"
Now, say that I wanted to include the reported version number in this message for the benefit of the user.
The docs for CPP say that:
Neither
#error
nor#warning
macro-expands its argument. Internal whitespace sequences are each replaced with a single space. The line must consist of complete tokens. It is wisest to make the argument of these directives be a single string constant; this avoids problems with apostrophes and the like.
This appears to preclude me from just sticking #OPENSSL_VERISON_NUMBER
onto the end of the message.
The author of this bit of code tried a stringification method detailed in this question, but it appears to not work:
#// used for manual warnings
#define XSTR(x) STR(x)
#define STR(x) #x
This leads to a warning reading:
warning: http_auth_ldap: Compiling with OpenSSL < 1.0.2, certificate verification will be unavailable. OPENSSL_VERSION_NUMBER == OPENSSL_VERSION_NUMBER [-W#pragma-messages]
..and a build failure. #pragma message
appears to suffer from the same no-macro-expansion limitation as #warning
.
Is there a sane way to concatenate the version string into the error?