struct -> object for extern structs
authorRobert Bradshaw <robertwb@math.washington.edu>
Wed, 8 Oct 2008 09:09:36 +0000 (02:09 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Wed, 8 Oct 2008 09:09:36 +0000 (02:09 -0700)
Cython/Compiler/PyrexTypes.py

index e22a7441d193a9669490af91cd6a3c371fc48d0a..b6519df5c83bd5b11d33c816228d010c755c44a4 100644 (file)
@@ -966,7 +966,13 @@ class CStructOrUnionType(CType):
             code.putln("Py_DECREF(res);")
             code.putln("return NULL;")
             code.putln("}")
-            self._convert_code = self.declaration_code('') + ';\n' + header+";", code.buffer.getvalue()
+            proto = header + ";"
+            # This is a bit of a hack, we need a forward declaration
+            # due to the way things are ordered in the module...
+            entry = env.lookup(self.name)
+            if entry.visibility != 'extern':
+                proto = self.declaration_code('') + ';\n' + proto
+            self._convert_code = proto, code.buffer.getvalue()
         
         env.use_utility_code(self._convert_code)
         return True