Index: tests/linking/mangling/.expect/anon.txt
===================================================================
--- tests/linking/mangling/.expect/anon.txt	(revision c2dfa56add568cd5de5c577ee3b9c646c9919748)
+++ tests/linking/mangling/.expect/anon.txt	(revision c2dfa56add568cd5de5c577ee3b9c646c9919748)
@@ -0,0 +1,1 @@
+Done!
Index: tests/linking/mangling/header.hfa
===================================================================
--- tests/linking/mangling/header.hfa	(revision e1d66c84e0c0d91acc25559fd73ab14706eee525)
+++ tests/linking/mangling/header.hfa	(revision c2dfa56add568cd5de5c577ee3b9c646c9919748)
@@ -8,6 +8,9 @@
 extern name_but_a_typedefed_t a_typedefed_global;
 
-extern struct /* anonymous */ {
-	int some_int;
-	int some_other_int;
-} a_global_with_no_type;
+// Must be extern C to prevent name mangling.
+extern "C" {
+	extern struct /* anonymous */ {
+		int some_int;
+		int some_other_int;
+	} a_global_with_no_type;
+}
Index: tests/linking/mangling/lib.cfa
===================================================================
--- tests/linking/mangling/lib.cfa	(revision e1d66c84e0c0d91acc25559fd73ab14706eee525)
+++ tests/linking/mangling/lib.cfa	(revision c2dfa56add568cd5de5c577ee3b9c646c9919748)
@@ -3,6 +3,10 @@
 name_but_a_typedefed_t a_typedefed_global;
 
-struct {
-	int some_int;
-	int some_other_int;
-} a_global_with_no_type;
+// Must be extern C to prevent name mangling.
+extern "C" {
+	// This declaration is necessary to create an instance of a_global_with_no_type.
+	// typeof is a trick to get a_global_with_no_type's type because its type is anonymous.
+	// Otherwise C generates conflicting types for a_global_with_no_type in .h and .c
+	// because C uses name equivalence and the two anonymous types cannot have the same name.
+	typeof(a_global_with_no_type) a_global_with_no_type;
+}
Index: tests/linking/mangling/main.cfa
===================================================================
--- tests/linking/mangling/main.cfa	(revision e1d66c84e0c0d91acc25559fd73ab14706eee525)
+++ tests/linking/mangling/main.cfa	(revision c2dfa56add568cd5de5c577ee3b9c646c9919748)
@@ -1,5 +1,5 @@
 #include <fstream.hfa>
 
-struct { int a; } test; //purposefully before the include
+static struct { int a; } test; // purposefully before the include to force anonymous name numbering
 
 #include "header.hfa"
@@ -13,5 +13,3 @@
 
 	sout | "Done!";
-
-	return 0;
 }
