Commit d19381e25e46db07617f91627a9fdc66b88aa0b3

Patrick Steinhardt 2018-06-25T14:57:07

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.

diff --git a/src/streams/mbedtls.c b/src/streams/mbedtls.c
index 0a49a36..7cecb2a 100644
--- a/src/streams/mbedtls.c
+++ b/src/streams/mbedtls.c
@@ -26,12 +26,23 @@
 #define GIT_DEFAULT_CERT_LOCATION NULL
 #endif
 
+/* Work around C90-conformance issues */
+#if defined(_MSC_VER)
+# define inline __inline
+#elif defined(__GNUC__)
+# define inline __inline__
+#else
+# define inline
+#endif
+
 #include <mbedtls/config.h>
 #include <mbedtls/ssl.h>
 #include <mbedtls/error.h>
 #include <mbedtls/entropy.h>
 #include <mbedtls/ctr_drbg.h>
 
+#undef inline
+
 mbedtls_ssl_config *git__ssl_conf;
 mbedtls_entropy_context *mbedtls_entropy;