diff -u -r ORBit2-20060506/ChangeLog ORBit2-20060506-kcc/ChangeLog
--- ORBit2-20060506/ChangeLog	2006-05-03 04:48:28.000000000 +0800
+++ ORBit2-20060506-kcc/ChangeLog	2006-05-06 04:01:39.000000000 +0800
@@ -1,3 +1,11 @@
+2006-05-06  Kuang-Chun Cheng <kccheng@linuxdaq-labs.org>
+
+	* src/idl-compiler/orbit-idl-c-headers.c:
+	Add guarding macros around emitted per interface enum of xyz_imethods[].
+	Fix Bug #340532.
+	* test/everything/client.c
+	Use ORBIT_METHODS_INDEX() for ORBit_small_invoke_async() test.
+
 2006-05-02  Kjartan Maraas  <kmaraas@gnome.org>
 
 	* configure.in: Remove SSL bits.
diff -u -r ORBit2-20060506/src/idl-compiler/orbit-idl-c-headers.c ORBit2-20060506-kcc/src/idl-compiler/orbit-idl-c-headers.c
--- ORBit2-20060506/src/idl-compiler/orbit-idl-c-headers.c	2006-05-02 18:10:18.000000000 +0800
+++ ORBit2-20060506-kcc/src/idl-compiler/orbit-idl-c-headers.c	2006-05-06 03:19:22.000000000 +0800
@@ -88,7 +88,7 @@
 	fullname = g_strconcat (id, "_", IDL_IDENT (
 		IDL_OP_DCL (tree).ident).str, NULL);
 
-	fprintf (of, "\t%s_IMETHODS_INDEX", fullname);
+	fprintf (of, "\t%s__imethods_index", fullname);
 
 	g_free (fullname);
 }
@@ -108,6 +108,10 @@
 			IDL_INTERFACE (i->tree).ident), "_", 0);
 
 		if (i->methods) {
+
+			fprintf (of, "#ifndef __%s__imethods_index\n", id);
+			fprintf (of, "#define __%s__imethods_index\n", id);
+
 			fprintf (of, "typedef enum {\n");
 
 			for (m = i->methods; m; m = m->next) {
@@ -118,7 +122,8 @@
 					fprintf(of, "\n");
 			}
 
-			fprintf (of, "} %s__imethods_index;\n\n", id);
+			fprintf (of, "} %s__imethods_index;\n", id);
+			fprintf (of, "#endif /* __%s__imethods_index */\n\n", id);
 		}
 
 		g_free (id);
@@ -175,7 +180,7 @@
 
   if (rinfo->idata) {
 	GSList *list = NULL;
-	fprintf (ci->fh, "\n/* IMethods index */\n\n");
+	fprintf (ci->fh, "\n/** IMethods index */\n\n");
                                                                                                            
 	list = ch_build_interfaces (list, tree);
 	ch_output_imethods_index (list, ci);
@@ -183,8 +188,8 @@
 
   fprintf(ci->fh, "#ifndef __ORBIT_IMETHODS_INDEX\n");
   fprintf(ci->fh, "#define __ORBIT_IMETHODS_INDEX\n");
-  fprintf(ci->fh, "#define ORBIT_IMETHODS_INDEX(m) (m ## _IMETHODS_INDEX)\n");
-  fprintf(ci->fh, "#endif /* __ORBIT_IMETHODS_INDEX */\n");
+  fprintf(ci->fh, "#define ORBIT_IMETHODS_INDEX(m) (m ## __imethods_index)\n");
+  fprintf(ci->fh, "#endif /* __ORBIT_IMETHODS_INDEX */\n\n");
 
   fprintf(ci->fh, "#ifdef __cplusplus\n");
   fprintf(ci->fh, "}\n");
diff -u -r ORBit2-20060506/test/everything/client.c ORBit2-20060506-kcc/test/everything/client.c
--- ORBit2-20060506/test/everything/client.c	2005-02-11 23:16:21.000000000 +0800
+++ ORBit2-20060506-kcc/test/everything/client.c	2006-05-06 03:50:06.000000000 +0800
@@ -1888,7 +1888,7 @@
 {
 	ORBit_IMethod *m_data;
 
-	m_data = &test_BasicServer__iinterface.methods._buffer [10];
+	m_data = &test_BasicServer__iinterface.methods._buffer [ORBIT_IMETHODS_INDEX(test_BasicServer_opException)];
 	/* if this failed, we re-ordered the IDL ... */
 	g_assert (!strcmp (m_data->name, "opException"));
 
@@ -1944,7 +1944,7 @@
 	args[1] = &inout_str;
 	args[2] = NULL;
 
-	m_data = &test_BasicServer__iinterface.methods._buffer[3];
+	m_data = &test_BasicServer__iinterface.methods._buffer[ORBIT_IMETHODS_INDEX(test_BasicServer_opString)];
 	/* if this failed, we re-ordered the IDL ... */
 	g_assert (!strcmp (m_data->name, "opString"));
 
