fix for gcc < 4.9
Costa Tsaousis (ktsaou) committed
Sep 27, 2016 at 02:22 UTC
e0aedc41c7bdd468b33cf84135a5e47a4ed3d818
2 files changed
+19
-3
src/common.h
+5
-3
@@ -65,9 +65,11 @@
65
#endif
66
67
#ifdef __GNUC__
68
-#define GCC_VERSION (__GNUC__ * 10000 \
69
- + __GNUC_MINOR__ * 100 \
70
- + __GNUC_PATCHLEVEL__)
68
+#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
69
+
70
+#if GCC_VERSION < 40900
71
+#define WITHOUT_C11_GENERIC 1
72
+#endif
73
74
#if __x86_64__ || __ppc64__
75
#define ENVIRONMENT64
src/log.c
+14
@@ -266,6 +266,18 @@ void info_int( const char *file, const char *function, const unsigned long line,
266
// ----------------------------------------------------------------------------
267
// error log
268
269
+#ifdef WITHOUT_C11_GENERIC
270
+
271
+#ifdef STRERROR_R_POSIX
272
+// POSIX version of strerror_r
273
+static const char *strerror_result(int a, const char *b) { (void)a; return b; }
274
+#else
275
+// GLIBC version of strerror_r
276
+static const char *strerror_result(const char *a, const char *b) { (void)b; return a; }
277
+#endif
278
+
279
+#else /* ! WITHOUT_C11_GENERIC */
280
+
281
// what a trick!
282
// http://stackoverflow.com/questions/479207/function-overloading-in-c
283
static const char *strerror_result_int(int a, const char *b) { (void)a; return b; }
@@ -276,6 +288,8 @@ static const char *strerror_result_string(const char *a, const char *b) { (void)
288
char *: strerror_result_string \
289
)(a, b)
290
291
+#endif /* ! WITHOUT_C11_GENERIC */
292
+
293
void error_int( const char *prefix, const char *file, const char *function, const unsigned long line, const char *fmt, ... )
294
{
295
va_list args;