[Freeciv-Dev] PATCH: log.h warning remove
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Hi,
the logdebug_suppress_warning does work for GCC only. Here
a patch to enable the warning-remove for other compilers as well
and also remove the useless code generated by the previous method.
The function stuff has been surrounded by an #ifndef and the
files including log.h without needing the freelog() function
need to define LOG_FREELOG_UNUSED before including it. Really
easy and does not waste program space.
Affects common/log.h server/civserver.c and server/console.c.
Ciao
____ _ _ ____ _ _ _ _ ____
| | | | | | \ / | | | the cool Gremlin from Bischofswerda
| __ | ____| | \/ | | | WWW: http://home.pages.de/~stoecker/
| | | | | | | | PGP key available on www page.
|____| _|_ |____| _|_ _|_ |____| I hope AMIGA never ends to make fun!
************************************************************************
* snail-mail: Dirk Stoecker * e-mail: *
* Geschwister-Scholl-Str. 10 * stoecker@xxxxxxxxxxxxxx *
* 01877 Bischofswerda * phone: *
* GERMANY * GERMANY +49 (0)3594/706666 *
************************************************************************
diff -ur ../../freeciv-cvs/freeciv/common/log.h ./common/log.h
--- ../../freeciv-cvs/freeciv/common/log.h Fri Sep 1 09:24:36 2000
+++ ./common/log.h Fri Sep 1 09:57:07 2000
@@ -59,10 +59,13 @@
void vreal_freelog(int level, char *message, va_list ap);
+#ifndef LOG_FREELOG_UNUSED
/* A static (per-file) function to use/update the above per-file vars.
* This should only be called for LOG_DEBUG messages.
* It returns whether such a LOG_DEBUG message should be sent on
* to real_freelog.
+ * Define LOG_FREELOG_UNUSED before including log.h when freelog() is
+ * not called, but log.h is included.
*/
#ifdef DEBUG
static int logdebug_check(const char *file, int line)
@@ -75,13 +78,6 @@
|| (line >= logdebug_thisfile.min
&& line <= logdebug_thisfile.max)));
}
-/* Including log.h without calling freelog() can generate a
- warning that logdebug_check is never used; can use this to
- suppress that warning:
-*/
-#define logdebug_suppress_warning logdebug_check(__FILE__, __LINE__)
-#else
-#define logdebug_suppress_warning
#endif
/* For GCC we use a variadic macro; for others we take
@@ -118,5 +114,6 @@
}
}
#endif /* __GNUC__ */
+#endif /* !LOG_FREELOG_UNUSED */
#endif /* FC__LOG_H */
diff -ur ../../freeciv-cvs/freeciv/server/civserver.c ./server/civserver.c
--- ../../freeciv-cvs/freeciv/server/civserver.c Fri Sep 1 09:24:59 2000
+++ ./server/civserver.c Fri Sep 1 09:56:38 2000
@@ -25,6 +25,7 @@
#endif
#include "fcintl.h"
+#define LOG_FREELOG_UNUSED
#include "log.h"
#include "shared.h"
#include "support.h"
@@ -51,7 +52,7 @@
int inx;
int showhelp = 0;
int showvers = 0;
- char *option = NULL;
+ char *option;
/* initialize server */
srv_init();
@@ -142,9 +143,6 @@
/* have arguments, call the main server loop... */
srv_main();
-
- /* suppress warnings */
- logdebug_suppress_warning;
/* done */
return 0;
diff -ur ../../freeciv-cvs/freeciv/server/console.c ./server/console.c
--- ../../freeciv-cvs/freeciv/server/console.c Fri Sep 1 09:24:56 2000
+++ ./server/console.c Fri Sep 1 09:56:40 2000
@@ -23,6 +23,7 @@
#endif
#include "fcintl.h"
+#define LOG_FREELOG_UNUSED
#include "log.h"
#include "support.h"
@@ -78,7 +79,6 @@
void con_log_init(char *log_filename, int log_level)
{
log_init(log_filename, log_level, (log_filename ? NULL : con_handle_log));
- logdebug_suppress_warning;
}
/************************************************************************
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] PATCH: log.h warning remove,
Dirk Stoecker <=
|
|