treewide: avoid use of `inline` attribute ISO C90 does not specify the `inline` attribute, and as such we cannot use it in our code. While we already use `__inline` when building in Microsoft Visual Studio, we should also be using the `__inline__` attribute from GCC/Clang. Otherwise, if we're using neither MSVC nor GCC/Clang, we should simply avoid using `inline` at all and just define functions as static. This commit adjusts our own `GIT_INLINE` macro as well as the inline macros specified by khash and xdiff. This allows us to enable strict C90 mode in a later commit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
diff --git a/src/common.h b/src/common.h
index 44063be..cb980c1 100644
--- a/src/common.h
+++ b/src/common.h
@@ -17,8 +17,10 @@
/** Declare a function as always inlined. */
#if defined(_MSC_VER)
# define GIT_INLINE(type) static __inline type
+#elif defined(__GNUC__)
+# define GIT_INLINE(type) static __inline__ type
#else
-# define GIT_INLINE(type) static inline type
+# define GIT_INLINE(type) static type
#endif
/** Support for gcc/clang __has_builtin intrinsic */
diff --git a/src/khash.h b/src/khash.h
index 71eb583..40e2d18 100644
--- a/src/khash.h
+++ b/src/khash.h
@@ -146,8 +146,10 @@ typedef unsigned long long khint64_t;
#ifndef kh_inline
#ifdef _MSC_VER
#define kh_inline __inline
+#elif defined(__GNUC__)
+#define kh_inline __inline__
#else
-#define kh_inline inline
+#define kh_inline
#endif
#endif /* kh_inline */
diff --git a/src/xdiff/xdiffi.c b/src/xdiff/xdiffi.c
index 3a71ef6..97db054 100644
--- a/src/xdiff/xdiffi.c
+++ b/src/xdiff/xdiffi.c
@@ -33,8 +33,10 @@
/** Declare a function as always inlined. */
#if defined(_MSC_VER)
# define XDL_INLINE(type) static __inline type
+#elif defined(__GNUC__)
+# define XDL_INLINE(type) static __inline__ type
#else
-# define XDL_INLINE(type) static inline type
+#define XDG_INLINE(type) static type
#endif
typedef struct s_xdpsplit {