Re: compile error with gcc 4



Emmanuele Bassi wrote:

On Mon, 2005-06-13 at 08:35 +0000, 文 见 wrote:
I got the following errors compiling CVS nautilus with gcc4 is it a bug?

gcc is becoming incresingly annoying, these days - although it has every
reason to complain about the signedness of xmlChar... :-)

Anyway, attached there's a quick fix for each xmlChar without a cast
that I've found inside libnautilus-private.

Regards,
Emmanuele.

------------------------------------------------------------------------

Index: libnautilus-private/nautilus-customization-data.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-customization-data.c,v
retrieving revision 1.32
diff -u -r1.32 nautilus-customization-data.c
--- libnautilus-private/nautilus-customization-data.c	10 Mar 2003 18:44:31 -0000	1.32
+++ libnautilus-private/nautilus-customization-data.c	13 Jun 2005 09:21:23 -0000
@@ -449,7 +449,7 @@
			/* loop through the entries, adding a mapping to the hash table */
			while (current_node != NULL) {
				display_name = eel_xml_get_property_translated (current_node, "display_name");
-				filename = xmlGetProp (current_node, "filename");
+				filename = xmlGetProp (current_node, (xmlChar *) "filename");
				if (display_name && filename) {
					g_hash_table_replace (data->name_map_hash, g_strdup (filename), g_strdup (display_name));
				}
Index: libnautilus-private/nautilus-metafile.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-metafile.c,v
retrieving revision 1.39
diff -u -r1.39 nautilus-metafile.c
--- libnautilus-private/nautilus-metafile.c	22 Nov 2004 15:24:36 -0000	1.39
+++ libnautilus-private/nautilus-metafile.c	13 Jun 2005 09:21:24 -0000
@@ -694,7 +694,7 @@
	g_return_val_if_fail (key != NULL, NULL);
	g_return_val_if_fail (key[0] != '\0', NULL);

-	property = xmlGetProp (node, key);
+	property = xmlGetProp (node, XML_CHAR (key));
	if (property == NULL) {
		result = g_strdup (default_metadata);
	} else {
@@ -720,11 +720,11 @@
	xmlNode *root;

	if (metafile->details->xml == NULL) {
-		set_metafile_contents (metafile, xmlNewDoc (METAFILE_XML_VERSION));
+		set_metafile_contents (metafile, xmlNewDoc (XML_CHAR (METAFILE_XML_VERSION)));
	}
	root = xmlDocGetRootElement (metafile->details->xml);
	if (root == NULL) {
-		root = xmlNewDocNode (metafile->details->xml, NULL, "directory", NULL);
+		root = xmlNewDocNode (metafile->details->xml, NULL, XML_CHAR ("directory"), NULL);
		xmlDocSetRootElement (metafile->details->xml, root);
	}

@@ -749,8 +749,8 @@
	
	if (create) {
		root = create_metafile_root (metafile);
-		node = xmlNewChild (root, NULL, "file", NULL);
-		xmlSetProp (node, "name", file_name);
+		node = xmlNewChild (root, NULL, XML_CHAR ("file"), NULL);
+		xmlSetProp (node, XML_CHAR ("name"), XML_CHAR (file_name));
		g_hash_table_insert (hash, xmlMemStrdup (file_name), node);
		return node;
	}
@@ -819,7 +819,7 @@

	/* Add or remove a property node. */
	if (node != NULL) {
-		property_node = xmlSetProp (node, key, value);
+		property_node = xmlSetProp (node, XML_CHAR (key), XML_CHAR (value));
		if (value == NULL) {
			xmlRemoveProp (property_node);
		}
@@ -859,7 +859,7 @@

			next = child->next;
			if (strcmp (child->name, list_key) == 0) {
-				property = xmlGetProp (child, list_subkey);
+				property = xmlGetProp (child, XML_CHAR (list_subkey));
				if (property != NULL && p != NULL
				    && strcmp (property, (char *) p->data) == 0) {
					p = p->next;
@@ -874,8 +874,8 @@
		
		/* Add any additional nodes needed. */
		for (; p != NULL; p = p->next) {
-			child = xmlNewChild (node, NULL, list_key, NULL);
-			xmlSetProp (child, list_subkey, p->data);
+			child = xmlNewChild (node, NULL, XML_CHAR (list_key), NULL);
+			xmlSetProp (child, XML_CHAR (list_subkey), XML_CHAR (p->data));
			changed = TRUE;
		}
	}
@@ -1288,7 +1288,7 @@
			xmlFree (key);
			g_hash_table_insert (hash,
					     xmlMemStrdup (new_file_name), value);
-			xmlSetProp (file_node, "name", new_file_name);
+			xmlSetProp (file_node, XML_CHAR ("name"), XML_CHAR (new_file_name));
			directory_request_write_metafile (metafile);
		}
	} else {
@@ -1417,7 +1417,7 @@
			node = xmlCopyNode (source_node, TRUE);
			root = create_metafile_root (destination_metafile);
			xmlAddChild (root, node);
-			xmlSetProp (node, "name", destination_file_name);
+			xmlSetProp (node, XML_CHAR ("name"), XML_CHAR (destination_file_name));
			g_hash_table_insert (destination_metafile->details->node_hash,
					     xmlMemStrdup (destination_file_name), node);
		} else {
@@ -1517,7 +1517,7 @@
	for (node = eel_xml_get_root_children (metafile_contents);
	     node != NULL; node = node->next) {
		if (strcmp (node->name, "file") == 0) {
-			name = xmlGetProp (node, "name");
+			name = xmlGetProp (node, XML_CHAR ("name"));
			if (g_hash_table_lookup (hash, name) != NULL) {
				xmlFree (name);
				/* FIXME: Should we delete duplicate nodes as we discover them? */
Index: libnautilus-private/nautilus-metafile.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-metafile.h,v
retrieving revision 1.13
diff -u -r1.13 nautilus-metafile.h
--- libnautilus-private/nautilus-metafile.h	4 Feb 2003 10:36:06 -0000	1.13
+++ libnautilus-private/nautilus-metafile.h	13 Jun 2005 09:21:24 -0000
@@ -28,6 +28,9 @@
#include <libnautilus-private/nautilus-metafile-server.h>
#include <libxml/tree.h>

+/* Hush gcc complaining about xmlChar's signedness */
+#define XML_CHAR(str)	((xmlChar *) (str))
+
#define NAUTILUS_TYPE_METAFILE	          (nautilus_metafile_get_type ())
#define NAUTILUS_METAFILE(obj)	          (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_METAFILE, NautilusMetafile))
#define NAUTILUS_METAFILE_CLASS(klass)    (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_METAFILE, NautilusMetafileClass))
Gcc 4.0.0 is a bad compiler. It doesn't compile kde, and I have even heard bad things about it and the linux kernel. I am sticking with 3.4.3, which was very stable. Hopefully 4.0.1 is better.
-Steven



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]