Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define SECP256K1_BUILD in secp256k1.c directly. #928

Merged
merged 1 commit into from
May 2, 2021
Merged

Define SECP256K1_BUILD in secp256k1.c directly. #928

merged 1 commit into from
May 2, 2021

Conversation

gmaxwell
Copy link
Contributor

@gmaxwell gmaxwell commented May 1, 2021

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

@sipa
Copy link
Contributor

sipa commented May 1, 2021

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.

@gmaxwell
Copy link
Contributor Author

gmaxwell commented May 1, 2021

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.

Copy link
Contributor

@real-or-random real-or-random left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK mod nit

include/secp256k1.h Show resolved Hide resolved
This avoids building without it and makes it safer to use a custom
 building environment.  Test harnesses need to #include secp256k1.c
 first now.
@sipa
Copy link
Contributor

sipa commented May 1, 2021

utACK ae9e648

Copy link
Contributor

@real-or-random real-or-random left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK ae9e648

@@ -4,6 +4,8 @@
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
***********************************************************************/

#define SECP256K1_BUILD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be wrapped in #ifndef SECP256k1_BUILD?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make it impossible to build without SECP256K1_BUILD defined
4 participants