This avoids building without it and makes it safer to use a custom building environment. Test harnesses need to #include secp256k1.c first now.
Fixes #927
Does this risk accidentally including secp256k1.h somewhere before secp256k1.c, thus getting the wrong interface definitions? If so, perhaps it's a possibility to have .h define a SECP256K1_NO_BUILD (if SECP256K1_BUILD wasn't defined already). .c can then error out if SECP256K1_NO_BUILD was defined.
Indeed and the PR fixed a couple tests that were doing exactly that. I didn't consider it much of a concern because the non-null warnings catch it in development... but you're absolutely right that this is easy to avoid and so I added your suggestion.
126 | @@ -127,6 +127,10 @@ typedef int (*secp256k1_nonce_function)( 127 | # define SECP256K1_INLINE inline 128 | # endif 129 | 130 | +#ifndef SECP256K1_BUILD 131 | +# define SECP256K1_NO_BUILD 132 | +#endif
nit: I think this would be a good place to spend one or two sentences to explain the purpose of these macros. (My personal experience: I think I had two ask a few times before I understood the entire concept.)
There is a comment below on the nullness macro. But I can add one to the guard about the guard specifically.
ACK mod nit
This avoids building without it and makes it safer to use a custom
building environment. Test harnesses need to #include secp256k1.c
first now.
utACK ae9e648526ceaf7cd97ba4dfe3c105db8e226c35
ACK ae9e648526ceaf7cd97ba4dfe3c105db8e226c35
3 | @@ -4,6 +4,8 @@ 4 | * file COPYING or https://www.opensource.org/licenses/mit-license.php.* 5 | ***********************************************************************/ 6 | 7 | +#define SECP256K1_BUILD
Shouldn't this be wrapped in #ifndef SECP256k1_BUILD?
I don't see why-- if it was you wouldn't have spotted that your rust build was incorrectly setting it now that it shouldn't be set that way anymore.
I just thought it was common practice to wrap defines in ifndef in the case that the define acts as a flag and doesn't carry any additional value.
(I don't think there was any harm in the fact that we kept passing -DSECP256K1_BUILD to the compiler, as we don't really use "headers" in rust)