>From 302564444383169087fbbec36983789abbac9aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Thu, 14 Feb 2013 02:32:22 +0000 Subject: [PATCH] build: avoid link failure in devmsg() on older linkers On linkers that don't remove unused functions, there will be a reference to a missing dev_debug symbol in the devmsg() function. So for now ... * src/system.h: ... move devmsg() from here ... * src/numfmt.c: ... to here, and document future cleanup. * src/factor.c: Likewise. --- src/factor.c | 18 +++++++++++++++++- src/numfmt.c | 21 ++++++++++++++++++--- src/system.h | 15 --------------- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/factor.c b/src/factor.c index df3d7a0..8f1542a 100644 --- a/src/factor.c +++ b/src/factor.c @@ -687,7 +687,23 @@ verify (W <= WIDE_UINT_BITS); /* debugging for developers. Enables devmsg(). This flag is used only in the GMP code. */ -bool dev_debug = false; +static bool dev_debug = false; + +/* Like error(0, 0, ...), but without an implicit newline. + Also a noop unless the global DEV_DEBUG is set. + TODO: Replace with variadic macro in system.h or + move to a separate module. */ +static inline void +devmsg (char const *fmt, ...) +{ + if (dev_debug) + { + va_list ap; + va_start (ap, fmt); + vfprintf (stderr, fmt, ap); + va_end (ap); + } +} /* Prove primality or run probabilistic tests. */ static bool flag_prove_primality = true; diff --git a/src/numfmt.c b/src/numfmt.c index 9a321d6..8c21c2b 100644 --- a/src/numfmt.c +++ b/src/numfmt.c @@ -190,13 +190,28 @@ static uintmax_t header = 0; error (similar to sort's debug). */ static bool debug; -/* debugging for developers. Enables devmsg(). */ -bool dev_debug = false; - /* will be set according to the current locale. */ static const char *decimal_point; static int decimal_point_length; +/* debugging for developers. Enables devmsg(). */ +static bool dev_debug = false; + +/* Like error(0, 0, ...), but without an implicit newline. + Also a noop unless the global DEV_DEBUG is set. + TODO: Replace with variadic macro in system.h or + move to a separate module. */ +static inline void +devmsg (char const *fmt, ...) +{ + if (dev_debug) + { + va_list ap; + va_start (ap, fmt); + vfprintf (stderr, fmt, ap); + va_end (ap); + } +} static inline int default_scale_base (enum scale_type scale) diff --git a/src/system.h b/src/system.h index 6c310ad..1677999 100644 --- a/src/system.h +++ b/src/system.h @@ -649,21 +649,6 @@ stzncpy (char *restrict dest, char const *restrict src, size_t len) return dest; } -/* Like error(0, 0, ...), but without an implicit newline. - Also a noop unless the global DEV_DEBUG is set. */ -extern bool dev_debug; -static inline void -devmsg (char const *fmt, ...) -{ - if (dev_debug) - { - va_list ap; - va_start (ap, fmt); - vfprintf (stderr, fmt, ap); - va_end (ap); - } -} - #ifndef ARRAY_CARDINALITY # define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) #endif -- 1.7.7.6