Skip to content

Commit c4e5832

Browse files
secp256k1.h: Guess availability of standard lib
1 parent 5e84c28 commit c4e5832

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

include/secp256k1.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,34 @@ typedef int (*secp256k1_nonce_function)(
122122
# endif
123123
# endif
124124

125+
/* SECP_HAVE_X is 1 iff standard library header X is available.
126+
*
127+
* We guess the values of HAVE_X here for various X. You can always override our
128+
* guess by providing a definition of the respective macro.
129+
*
130+
* Note to developers of the library: All SECP256K1_HAVE_X macros will always be
131+
* defined after this section, so use #if instead #ifdef to check them. */
132+
#if !defined(SECP256K1_HAVE_STDIO_H)
133+
# if defined(__has_include)
134+
# define SECP256K1_HAVE_STDIO_H (__has_include(<stdio.h>))
135+
# elif defined(__STDC_HOSTED__)
136+
# define SECP256K1_HAVE_STDIO_H __STDC_HOSTED__
137+
# else
138+
/* Unreachable with a confirming compiler. Guess "yes" as a last resort. */
139+
# define SECP256K1_HAVE_STDIO_H 1
140+
# endif
141+
#endif
142+
#if !defined(SECP256K1_HAVE_STDLIB_H)
143+
# if defined(__has_include)
144+
# define SECP256K1_HAVE_STDLIB_H (__has_include(<stdlib.h>))
145+
# elif defined(__STDC_HOSTED__)
146+
# define SECP256K1_HAVE_STDLIB_H __STDC_HOSTED__
147+
# else
148+
/* Unreachable with a confirming compiler. Guess "yes" as a last resort. */
149+
# define SECP256K1_HAVE_STDLIB_H 1
150+
# endif
151+
#endif
152+
125153
/* When this header is used at build-time the SECP256K1_BUILD define needs to be set
126154
* to correctly setup export attributes and nullness checks. This is normally done
127155
* by secp256k1.c but to guard against this header being included before secp256k1.c

0 commit comments

Comments
 (0)