On Sun, Jan 11, 2015 at 3:14 PM, Niels Möller nisse@lysator.liu.se wrote:
I'd prefer either a separate file nettle/version.h, or some file like nettle-typs.h included in all other nettle headers. And if we let configure generate a header file, it makes some sense to also move the definition of NETTLE_USE_MINI_GMP there, and move back from bignum-h-in to bignum.h. And I'm also not sure I like the way major and minor numbers are combined into a single value. Can't they be kept separate, say NETTLE_VERSION, NETTLE_MINOR_VERSION, NETTLE_PATCHLEVEL or so? What do other packages do? E.g., gcc uses $ echo | cpp -dM -E - |grep GNUC #define __GNUC_PATCHLEVEL__ 2 #define __GNUC__ 4 #define __GNUC_MINOR__ 7
I needed the version check in order to have two versions of a program, one for the pre-3 API and one for the post. Having only two definitions would make the complete version check harder. However, if both approaches are present it would be best. For the two definitions approach it would also make sense to associate some guarrantees for them, otherwise using them wouldn't provide much benefit.
Maybe there should also be correspondingglobal symbols, so that version can be checked also at runtime?
libgcrypt defines gcry_check_version() which is a good version checker for runtime. However, given the low-level nature of nettle, I'm not sure whether having such a function would provide much. Such runtime checks are nice on high level APIs which may have an additional feature in some version (e.g. for gcry_cipher_open one could have a runtime check for a particular algorithm). For nettle, the API and ABI are so low-level one can simply check for the specific function.
https://www.gnupg.org/documentation/manuals/gcrypt/Initializing-the-library....
regards, Nikos