secp256k1 icon indicating copy to clipboard operation
secp256k1 copied to clipboard

Don't #include standard library headers unconditionally

Open real-or-random opened this issue 2 years ago • 6 comments

We currently include <stdio.h> for fprintf used in the a) tests and b) in the default error callbacks ... We should not include the header unconditionally.

https://github.com/bitcoin-core/secp256k1/blob/912b7ccc4473b5c969b01d027b8d5dc515435eb5/src/util.h#L16

This is a problem downstream in https://github.com/rust-bitcoin/rust-secp256k1/pull/421 .

edit: We have a similar issue for stdlib.h but it is a little bit more complicated. It has abort, and malloc/free. The story for abort is the same as for fprintf. Strictly speaking one doesn't need malloc/free if one uses the prealloc interface but we don't provide consistent include headers for this. (You'll need the normal plus the prealloc header...) So people need to patch our sources which is anything but elegant. https://github.com/rust-bitcoin/rust-secp256k1/blob/master/secp256k1-sys/depend/secp256k1.c.patch

real-or-random avatar Mar 28 '22 14:03 real-or-random