secp256k1_xonly_pubkey_load is used in modules/schnorrsig/main_impl.h but there is declaration for it.
No declaration for `secp256k1_xonly_pubkey_load`. #872
issue roconnor-blockstream opened this issue on January 20, 2021-
roconnor-blockstream commented at 9:30 PM on January 20, 2021: contributor
-
roconnor-blockstream commented at 6:37 PM on January 22, 2021: contributor
Similarly
secp256k1_pubkey_loadis used inmodules/extrakeys/main_impl.hbut there is no declaration for it. -
elichai commented at 9:44 AM on September 15, 2021: contributor
Where should they be declared though? it seems like the only place it makes since is on top of the same
main_impl.hfile?Should static functions even be declared before implementation?
-
roconnor-blockstream commented at 11:43 AM on September 15, 2021: contributor
Please correct me if I'm wrong, but my understanding is that functions defined in one file but used in other files ought to have declarations.
-
elichai commented at 12:06 PM on September 15, 2021: contributor
@roconnor-blockstream oh right, extrakeys and schnorrsig are separate files that depend on each other.
I guess this only works because of the order in which they are included in
secp256k1.c -
sipa commented at 12:17 PM on September 15, 2021: contributor
Declarations are only necessary when calling a function defined in another compilation unit. Libsecp256k1 is compiled as a single compilation unit (even though some optional parts are called "modules"); everything is directly or indirectly #include'd from
secp256k1.c. So only API functions (which can be called from outside the library) strictly speaking need declarations.Declarations are also necessary for functions that are called before being defined, which happens e.g. when making mutually recursive calls. I don't think we have any instances of that in the codebase.
The compiler will warn if a function is called without definition, so I'm pretty sure everything is ok.
We do have declarations in e.g. field.h and group.h, but those just serve as compiler-checked developer documentation for the implementations and "interface" to that part of the codebase. They're redundant technically speaking.
-
roconnor-blockstream commented at 1:52 PM on September 15, 2021: contributor
Right. My understanding is that
secp256k1_xonly_pubkey_loadand friends ought to have (but isn't required to have) "compiler-checked developer documentation for the implementations and 'interface' to that part of the codebase", and that is what this issue is about. If I'm wrong, then we should close this issue. -
real-or-random commented at 2:00 PM on September 15, 2021: contributor
Hm, that's a valid point. In general, we have only
_impl.hfiles in the modules but no files for the internal API exposed by the modules, andschnorrsigdepends onextrakeysfor example. -
sipa commented at 2:37 PM on September 15, 2021: contributor
Right. My understanding is that secp256k1_xonly_pubkey_load and friends ought to have (but isn't required to have) "compiler-checked developer documentation for the implementations and 'interface' to that part of the codebase", and that is what this issue is about.
Oh, yes, I agree with that.