[Freeciv-Dev] Re: compile errors on bitvector code with Sun cc (PR#2046)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Mike Kaufman wrote:
On Sat, Sep 28, 2002 at 10:19:06AM -0500, Mike Kaufman wrote:
On Sat, Sep 28, 2002 at 08:05:55AM -0700, Per I. Mathisen wrote:
On Fri, 27 Sep 2002, Jason Short wrote:
The problem is Sun CC, at least, doesn't support variadic macros
(variable options in macros).For freelog there's an "#ifdef __GNUC__"
check, with a static function declared in the header for other compilers.
As I understand it, the reason it's important to have this code be
macros/inlined is that there are a LOT of freelog calls throughout the
code, and most of them can be optimized away
The problem itself can be optimized away. Since all developers use gcc,
and only developers watch these log messages, we can add gcc to the list
of development tools that are needed to program for freeciv, and #ifdef
__GNUC__ the macros. You will need the rest of the GNU toolchain
(automake, autoconf, gettext, etc) in order to build from cvs anyway.
hmm. at least for the immediate, I don't think we're saving ourselves much,
since these macros all call a bunch of functions themselves. An extra hop
isn't really going to mean much. I suggest an ailog.c and make these macros
functions.
BTW: we should be using my_snprintf instead of sprintf in those routines.
and a patch to do this.
it also runs slightly faster than the CVS version.
With the application of this patch and the one-line fix to remove the
other warning, the original bug report has been addressed.
But, FreeCiv still won't compile under Sun CC. There are two warnings
and an error for the server.
"autoattack.c", line 102: warning: enum type mismatch: arg #2
This seems to be a rather spurious warning involving enums. It's easily
fixed, though, and the rewrite makes things more readible.
"console.c", line 88: identifier redeclared: con_dump
This is becaus the prototypes for con_dump (and con_write/con_puts)
don't match up. One uses an enum, the other an int. Easily fixed.
"diplhand.c", line 213: warning: improper pointer/integer combination:
arg #2
There are a number of warnings like this; they seem to occur anywhere a
PL_ is used. I'm not sure why (I'm using --with-included-gettext).
Patch attached.
jason
? config.h.diff
? configure.diff
? debian.diff
? diff
? freeciv-patches.tgz
? gtk-warnings.diff
? gtk2-warnings.diff
? jason-game.gz
? ndebug-warning.diff
? option_callback.diff
? rc
? suncc3.diff
? test.pl
? tileset_switching-3.diff
? ai/output
Index: server/autoattack.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/autoattack.c,v
retrieving revision 1.39
diff -u -r1.39 autoattack.c
--- server/autoattack.c 2002/09/27 12:32:45 1.39
+++ server/autoattack.c 2002/09/30 03:42:38
@@ -98,8 +98,8 @@
}
freelog(LOG_DEBUG, "defender is %s", unit_name(enemy->type));
- if (!is_city_option_set(pcity, unit_type(enemy)->move_type - 1 +
- CITYO_ATT_LAND)) {
+ if (!is_city_option_set(pcity, CITYO_ATT_LAND
+ + unit_type(enemy)->move_type - 1)) {
freelog(LOG_DEBUG, "wrong target type");
continue;
}
Index: server/console.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/console.c,v
retrieving revision 1.17
diff -u -r1.17 console.c
--- server/console.c 2002/09/27 12:32:46 1.17
+++ server/console.c 2002/09/30 03:42:38
@@ -84,7 +84,7 @@
/************************************************************************
Write to console without line-break, don't print prompt.
************************************************************************/
-int con_dump(int i, const char *message, ...)
+int con_dump(enum rfc_status rfc_status, const char *message, ...)
{
static char buf[MAX_LEN_CONSOLE_LINE];
va_list args;
@@ -96,8 +96,8 @@
if(console_prompt_is_showing) {
printf("\n");
}
- if ((console_rfcstyle) && (i >= 0)) {
- printf("%.3d %s", i, buf);
+ if ((console_rfcstyle) && (rfc_status >= 0)) {
+ printf("%.3d %s", rfc_status, buf);
} else {
printf("%s", buf);
}
@@ -108,7 +108,7 @@
/************************************************************************
Write to console and add line-break, and show prompt if required.
************************************************************************/
-void con_write(int i, const char *message, ...)
+void con_write(enum rfc_status rfc_status, const char *message, ...)
{
static char buf[MAX_LEN_CONSOLE_LINE];
va_list args;
@@ -117,7 +117,7 @@
my_vsnprintf(buf, sizeof(buf), message, args);
va_end(args);
- con_puts(i, buf);
+ con_puts(rfc_status, buf);
}
/************************************************************************
@@ -127,13 +127,13 @@
with con_write(C_COMMENT,"") of "warning: zero-length format string";
this allows con_puts(C_COMMENT,"");
************************************************************************/
-void con_puts(int i, const char *str)
+void con_puts(enum rfc_status rfc_status, const char *str)
{
if(console_prompt_is_showing) {
printf("\n");
}
- if ((console_rfcstyle) && (i >= 0)) {
- printf("%.3d %s\n", i, str);
+ if ((console_rfcstyle) && (rfc_status >= 0)) {
+ printf("%.3d %s\n", rfc_status, str);
} else {
printf("%s\n", str);
}
|
|