From 2c24d433d1b5da7e88fd37ec715bf8a5c0c10e04 Mon Sep 17 00:00:00 2001 From: Volker Mische Date: Tue, 8 Jul 2014 15:17:02 +0200 Subject: [PATCH] Don't inline when compiling with Clang Clang has a different behaviour than GCC when it comes to inlining functions. Sadly Clang identifies itself as __GNUC__, hence the define to prevent non-GCC compilers to use the inline keyword didn't work. This commit solves the problem with adding an additional check to the define, that the compiler isn't Clang. During compilation you get warnings like: In file included from linux_sigar.c:30: ../../../include/sigar_util.h:80:20: warning: inline function 'sigar_skip_token' is not defined [-Wundefined-inline] SIGAR_INLINE char *sigar_skip_token(char *p); ^ linux_sigar.c:137:24: note: used here if ((ptr = sigar_skip_token(ptr))) { ^ Which end up in an error like: libtool: link: clang -g -O2 -o .libs/cpuinfo cpuinfo.o ../src/.libs/libsigar.so ../src/.libs/libsigar.so: undefined reference to `sigar_skip_token' clang: error: linker command failed with exit code 1 (use -v to see invocation) --- include/sigar_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sigar_private.h b/include/sigar_private.h index 484f83064..ee07ea0f5 100644 --- a/include/sigar_private.h +++ b/include/sigar_private.h @@ -73,7 +73,7 @@ #if defined(WIN32) # define SIGAR_INLINE __inline -#elif defined(__GNUC__) +#elif defined(__GNUC__) && !defined(__clang__) # define SIGAR_INLINE inline #else # define SIGAR_INLINE