[Freeciv-Dev] configure check for variadic macros (PR#6254)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Here's a slightly changed version.
- configure.in support added back in (sometimes autogen.sh hides
configure.in, causing it to be left out of the patch).
- variadic_macros.m4 is renamed to c99.m4. This can contain other c99
checks in future.
jason
# Check for the presense of C99 features. These may be optional or required.
# Check C99-style variadic macros (required):
#
# #define PRINTF(msg, ...) (printf(msg, __VA_ARGS__)
#
AC_DEFUN(FC_VARIADIC_MACROS,
[
dnl Check for variadic macros
AC_CACHE_CHECK([for C99 variadic macros],
[ac_cv_c99_variadic_macros],
[AC_TRY_COMPILE(
[#include <stdio.h>
#define MSG(...) fprintf(stderr, __VA_ARGS__)
],
[MSG("foo");
MSG("%s", "foo");
MSG("%s%d", "foo", 1);],
ac_cv_c99_variadic_macros=yes,
ac_cv_c99_variadic_macros=no)])
echo "${CFLAGS_save}"
if test "x${ac_cv_c99_variadic_macros}" != "xyes"; then
AC_MSG_ERROR([A compiler supporting C99 variadic macros is required])
fi
])
? m4/vararrays.m4
Index: Makefile.am
===================================================================
RCS file: /home/freeciv/CVS/freeciv/Makefile.am,v
retrieving revision 1.33
diff -u -r1.33 Makefile.am
--- Makefile.am 2003/09/19 18:29:40 1.33
+++ Makefile.am 2003/10/01 20:36:47
@@ -66,6 +66,7 @@
debian/watch \
m4/ac_path_lib.m4 \
m4/auth.m4 \
+ m4/c99.m4 \
m4/debug.m4 \
m4/esd.m4 \
m4/freetype2.m4 \
Index: configure.ac
===================================================================
RCS file: /home/freeciv/CVS/freeciv/configure.ac,v
retrieving revision 1.50
diff -u -r1.50 configure.ac
--- configure.ac 2003/07/31 19:18:40 1.50
+++ configure.ac 2003/10/01 20:36:47
@@ -263,6 +263,7 @@
fi
FC_DEBUG
+FC_VARIADIC_MACROS
if test "$CVS_DEPS" = "maybe"; then
dnl Should also check for gmake?
Index: configure.in
===================================================================
RCS file: /home/freeciv/CVS/freeciv/configure.in,v
retrieving revision 1.226
diff -u -r1.226 configure.in
--- configure.in 2003/07/31 19:18:40 1.226
+++ configure.in 2003/10/01 20:36:47
@@ -262,6 +262,7 @@
fi
FC_DEBUG
+FC_VARIADIC_MACROS
if test "$CVS_DEPS" = "maybe"; then
dnl Should also check for gmake?
Index: common/log.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/log.h,v
retrieving revision 1.20
diff -u -r1.20 log.h
--- common/log.h 2002/10/29 18:50:06 1.20
+++ common/log.h 2003/10/01 20:36:47
@@ -87,39 +87,20 @@
#define logdebug_suppress_warning
#endif
-/* For GCC we use a variadic macro; for others we take
- the performance hit of a function to get variadic args:
-*/
-#ifdef __GNUC__
#ifdef DEBUG
-#define freelog(level, args...) do { \
- if ((level) != LOG_DEBUG || logdebug_check(__FILE__, __LINE__)) { \
- real_freelog((level), args); \
- } \
-} while(FALSE)
+# define freelog(level, ...) \
+ do { \
+ if ((level) != LOG_DEBUG || logdebug_check(__FILE__, __LINE__)) { \
+ real_freelog((level), __VA_ARGS__); \
+ } \
+ } while(FALSE)
#else
-#define freelog(level, args...) do { \
- if ((level) != LOG_DEBUG) { \
- real_freelog((level), args); } \
-} while(FALSE)
+# define freelog(level, ...) \
+ do { \
+ if ((level) != LOG_DEBUG) { \
+ real_freelog((level), __VA_ARGS__); \
+ } \
+ } while(FALSE)
#endif /* DEBUG */
-#else
-/* non-GCC: */
-static void freelog(int level, const char *message, ...)
-{
- bool log_this;
-#ifdef DEBUG
- log_this = (level != LOG_DEBUG || logdebug_check(__FILE__, __LINE__));
-#else
- log_this = (level != LOG_DEBUG);
-#endif
- if (log_this) {
- va_list args;
- va_start(args, message);
- vreal_freelog(level, message, args);
- va_end(args);
- }
-}
-#endif /* __GNUC__ */
#endif /* FC__LOG_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] configure check for variadic macros (PR#6254),
Jason Short <=
|
|