Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f347a44

Browse files
committed
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 parent 6dfc8bc commit f347a44

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
/** Declare a function as always inlined. */
1818
#if defined(_MSC_VER)
1919
# define GIT_INLINE(type) static __inline type
20+
#elif defined(__GNUC__)
21+
# define GIT_INLINE(type) static __inline__ type
2022
#else
21-
# define GIT_INLINE(type) static inline type
23+
# define GIT_INLINE(type) static type
2224
#endif
2325

2426
/** Support for gcc/clang __has_builtin intrinsic */

src/khash.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ typedef unsigned long long khint64_t;
146146
#ifndef kh_inline
147147
#ifdef _MSC_VER
148148
#define kh_inline __inline
149+
#elif defined(__GNUC__)
150+
#define kh_inline __inline__
149151
#else
150-
#define kh_inline inline
152+
#define kh_inline
151153
#endif
152154
#endif /* kh_inline */
153155

src/xdiff/xdiffi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
/** Declare a function as always inlined. */
3434
#if defined(_MSC_VER)
3535
# define XDL_INLINE(type) static __inline type
36+
#elif defined(__GNUC__)
37+
# define XDL_INLINE(type) static __inline__ type
3638
#else
37-
# define XDL_INLINE(type) static inline type
39+
#define XDG_INLINE(type) static type
3840
#endif
3941

4042
typedef struct s_xdpsplit {

0 commit comments

Comments
 (0)