Skip to content

Commit d19381e

Browse files
committed
mbedtls: fix inline being used in mbedtls headers
The mbedtls headers make direct use of the `inline` attribute to instruct the compiler to inline functions. As this function is not C90 compliant, this can cause the compiler to error as soon as any of these files is included and the `-std=c90` flag is being added. The mbedtls headers declaring functions as inline always have a prelude which define `inline` as a macro in case it is not yet defined. Thus, we can easily replace their define with our own define, which simply copies the logic of our own `GIT_INLINE` macro.
1 parent c13e56f commit d19381e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/streams/mbedtls.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,23 @@
2626
#define GIT_DEFAULT_CERT_LOCATION NULL
2727
#endif
2828

29+
/* Work around C90-conformance issues */
30+
#if defined(_MSC_VER)
31+
# define inline __inline
32+
#elif defined(__GNUC__)
33+
# define inline __inline__
34+
#else
35+
# define inline
36+
#endif
37+
2938
#include <mbedtls/config.h>
3039
#include <mbedtls/ssl.h>
3140
#include <mbedtls/error.h>
3241
#include <mbedtls/entropy.h>
3342
#include <mbedtls/ctr_drbg.h>
3443

44+
#undef inline
45+
3546
mbedtls_ssl_config *git__ssl_conf;
3647
mbedtls_entropy_context *mbedtls_entropy;
3748

0 commit comments

Comments
 (0)