[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] union in gnugo3.5.6
From: |
Wolfgang Manner |
Subject: |
[gnugo-devel] union in gnugo3.5.6 |
Date: |
Tue, 4 May 2004 16:28:48 +0200 (CEST) |
Friends !
At work i have gcc 3.2 and gnugo-3.5.6 compiles perfectly.
However at home i have gcc 2.95 and that doesnt like the
anonymous union in patterns/patterns.h
so i propose to name the union.
That way you can also get rid of the
ifdef __GNUC__
so here is the patch (against gnugo-3.5.6)
wolfgang
diff -u -N -r gnugo-3.5.6/engine/owl.c gnugo-3.5.6mod/engine/owl.c
--- gnugo-3.5.6/engine/owl.c Fri Apr 23 05:06:57 2004
+++ gnugo-3.5.6mod/engine/owl.c Tue May 4 15:59:58 2004
@@ -3853,7 +3853,7 @@
attribute->type != LAST_ATTRIBUTE;
attribute++) {
int k;
- int target = AFFINE_TRANSFORM(attribute->offset, pattern_data->ll,
+ int target = AFFINE_TRANSFORM(attribute->A.offset, pattern_data->ll,
pattern_data->move);
switch (attribute->type) {
diff -u -N -r gnugo-3.5.6/engine/shapes.c gnugo-3.5.6mod/engine/shapes.c
--- gnugo-3.5.6/engine/shapes.c Wed Mar 24 18:37:48 2004
+++ gnugo-3.5.6mod/engine/shapes.c Tue May 4 15:59:58 2004
@@ -87,7 +87,7 @@
for (attribute = attributes; attribute->type != LAST_ATTRIBUTE;
attribute++) {
if (attribute->type == SHAPE) {
- shape_value = attribute->value;
+ shape_value = attribute->A.value;
min_value *= (1 + 0.01 * shape_value);
break;
}
@@ -143,23 +143,23 @@
attribute++) {
switch (attribute->type) {
case MIN_VALUE:
- set_minimum_move_value(move, attribute->value);
- TRACE("...(min) move value %f\n", attribute->value);
+ set_minimum_move_value(move, attribute->A.value);
+ TRACE("...(min) move value %f\n", attribute->A.value);
break;
case MAX_VALUE:
- set_maximum_move_value(move, attribute->value);
- TRACE("...max move value %f\n", attribute->value);
+ set_maximum_move_value(move, attribute->A.value);
+ TRACE("...max move value %f\n", attribute->A.value);
break;
case MIN_TERRITORY:
- set_minimum_territorial_value(move, attribute->value);
- TRACE("...(min) territorial value %f\n", attribute->value);
+ set_minimum_territorial_value(move, attribute->A.value);
+ TRACE("...(min) territorial value %f\n", attribute->A.value);
break;
case MAX_TERRITORY:
- set_maximum_territorial_value(move, attribute->value);
- TRACE("...max territorial value %f\n", attribute->value);
+ set_maximum_territorial_value(move, attribute->A.value);
+ TRACE("...max territorial value %f\n", attribute->A.value);
break;
case SHAPE:
@@ -167,20 +167,20 @@
* already.
*/
if (!(class & (CLASS_j | CLASS_t))) {
- add_shape_value(move, attribute->value);
- TRACE("...shape value %f\n", attribute->value);
+ add_shape_value(move, attribute->A.value);
+ TRACE("...shape value %f\n", attribute->A.value);
}
break;
case FOLLOWUP:
- add_followup_value(move, attribute->value);
- TRACE("...followup value %f\n", attribute->value);
+ add_followup_value(move, attribute->A.value);
+ TRACE("...followup value %f\n", attribute->A.value);
break;
case REVERSE_FOLLOWUP:
- add_reverse_followup_value(move, attribute->value);
- TRACE("...reverse followup value %f\n", attribute->value);
+ add_reverse_followup_value(move, attribute->A.value);
+ TRACE("...reverse followup value %f\n", attribute->A.value);
break;
default:
diff -u -N -r gnugo-3.5.6/patterns/mkpat.c gnugo-3.5.6mod/patterns/mkpat.c
--- gnugo-3.5.6/patterns/mkpat.c Wed Mar 24 18:37:49 2004
+++ gnugo-3.5.6mod/patterns/mkpat.c Tue May 4 16:00:04 2004
@@ -1059,7 +1059,7 @@
attribute->type != LAST_ATTRIBUTE;
attribute++) {
if (attribute->type >= FIRST_OFFSET_ATTRIBUTE) {
- int label = attribute->offset;
+ int label = attribute->A.offset;
int x;
int y;
@@ -1074,7 +1074,7 @@
TRANSFORM2(label_coords[label][0] - ci - movei,
label_coords[label][1] - cj - movej, &x, &y,
labels_transformation);
- attribute->offset = OFFSET(x, y);
+ attribute->A.offset = OFFSET(x, y);
}
}
}
@@ -1220,10 +1220,10 @@
continue;
}
- attributes[num_attributes].offset = *(paren + 1);
+ attributes[num_attributes].A.offset = *(paren + 1);
}
else
- sscanf(paren + 1, "%f", &attributes[num_attributes].value);
+ sscanf(paren + 1, "%f", &attributes[num_attributes].A.value);
num_attributes++;
}
@@ -1256,7 +1256,7 @@
if (pattern[patno].attributes != NULL) {
attributes[num_attributes].type = LAST_ATTRIBUTE;
- attributes[num_attributes].value = 0.0;
+ attributes[num_attributes].A.value = 0.0;
num_attributes++;
}
@@ -2715,33 +2715,20 @@
int k;
fprintf(outfile, "static struct pattern_attribute attributes[] = {\n");
- fprintf(outfile, "#ifdef __GNUC__\n");
for (k = 0; k < num_attributes; k++) {
fprintf(outfile, " {%s,", attribute_name[attributes[k].type]);
if (attributes[k].type >= FIRST_OFFSET_ATTRIBUTE)
- fprintf(outfile, "{.offset=%d}}", attributes[k].offset);
+ fprintf(outfile, "{.offset=%d}}", attributes[k].A.offset);
else
- fprintf(outfile, "{.value=%f}}", attributes[k].value);
+ fprintf(outfile, "{.value=%f}}", attributes[k].A.value);
if (k != num_attributes - 1)
fprintf(outfile, ",\n");
}
- fprintf(outfile, "\n#else\n");
+ fprintf(outfile,"\n};\n\n");
- for (k = 0; k < num_attributes; k++) {
- fprintf(outfile, " {%s,", attribute_name[attributes[k].type]);
- if (attributes[k].type >= FIRST_OFFSET_ATTRIBUTE)
- fprintf(outfile, "0.0,%d}", attributes[k].offset);
- else
- fprintf(outfile, "%f,0}", attributes[k].value);
-
- if (k != num_attributes - 1)
- fprintf(outfile, ",\n");
- }
-
- fprintf(outfile,"\n#endif\n};\n\n");
}
diff -u -N -r gnugo-3.5.6/patterns/patterns.h gnugo-3.5.6mod/patterns/patterns.h
--- gnugo-3.5.6/patterns/patterns.h Wed Mar 24 18:37:49 2004
+++ gnugo-3.5.6mod/patterns/patterns.h Tue May 4 16:00:04 2004
@@ -202,9 +202,6 @@
LAST_ATTRIBUTE = NUM_ATTRIBUTES
};
-
-#ifdef __GNUC__
-
struct pattern_attribute {
enum attribute_type type;
@@ -212,19 +209,8 @@
union {
float value;
int offset;
- };
+ } A;
};
-
-#else
-
-struct pattern_attribute {
- enum attribute_type type;
- float value;
- int offset;
-};
-
-#endif
-
/*
* Each pattern as a whole is compiled to an instance of this structure.
- [gnugo-devel] union in gnugo3.5.6,
Wolfgang Manner <=