Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix cpython.array declaration order.

  • Loading branch information...
commit 5941a5b71345307ad075c75f0d4cfea12e15242c 1 parent 2fdc8d3
@robertwb robertwb authored
Showing with 14 additions and 4 deletions.
  1. +7 −0 Cython/Compiler/ModuleNode.py
  2. +7 −4 Cython/Utility/arrayarray.h
View
7 Cython/Compiler/ModuleNode.py
@@ -479,6 +479,13 @@ def generate_declarations_for_modules(self, env, modules, globalstate):
typecode = globalstate['type_declarations']
typecode.putln("")
typecode.putln("/*--- Type declarations ---*/")
+ # This is to work around the fact that array.h isn't part of the C-API,
+ # but we need to declare it earlier than utility code.
+ if 'cpython.array' in [m.qualified_name for m in modules]:
+ typecode.putln('#ifndef _ARRAYARRAY_H')
+ typecode.putln('struct arrayobject;')
+ typecode.putln('typedef struct arrayobject arrayobject;')
+ typecode.putln('#endif')
vtab_list, vtabslot_list = self.sort_type_hierarchy(modules, env)
self.generate_type_definitions(
env, modules, vtab_list, vtabslot_list, typecode)
View
11 Cython/Utility/arrayarray.h
@@ -13,7 +13,11 @@
#ifndef _ARRAYARRAY_H
#define _ARRAYARRAY_H
-struct arrayobject; /* Forward */
+// These two forward declarations are explicitly handled in the type
+// declaration code, as including them here is too late for cython-defined
+// types to use them.
+// struct arrayobject;
+// typedef struct arrayobject arrayobject;
// All possible arraydescr values are defined in the vector "descriptors"
// below. That's defined later because the appropriate get and set
@@ -29,7 +33,7 @@ typedef struct arraydescr {
} arraydescr;
-typedef struct arrayobject {
+struct arrayobject {
PyObject_HEAD
Py_ssize_t ob_size;
union {
@@ -54,8 +58,7 @@ typedef struct arrayobject {
#if PY_VERSION_HEX >= 0x03000000
int ob_exports; /* Number of exported buffers */
#endif
-} arrayobject;
-
+};
#ifndef NO_NEWARRAY_INLINE
// fast creation of a new array
Please sign in to comment.
Something went wrong with that request. Please try again.