guard C code from inclusion of gecompanion h api code
authorLisandro Dalcin <dalcinl@gmail.com>
Wed, 30 Mar 2011 23:09:36 +0000 (20:09 -0300)
committerLisandro Dalcin <dalcinl@gmail.com>
Wed, 30 Mar 2011 23:09:36 +0000 (20:09 -0300)
Cython/Compiler/ModuleNode.py
tests/compile/a_capi.pyx

index a66d43b70413f3b5730a9c75803fabdd10ecacc4..ae5c90bf08522fadda6bc5f251b20487cb5f6029 100644 (file)
@@ -112,12 +112,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
                 i_code = Code.PyrexCodeWriter(result.i_file)
             else:
                 i_code = None
-            guard = Naming.h_guard_prefix + env.qualified_name.replace(".", "__")
-            h_code.put_h_guard(guard)
+
+            h_guard = Naming.h_guard_prefix + self.api_name(env)
+            h_code.put_h_guard(h_guard)
             self.generate_extern_c_macro_definition(h_code)
             self.generate_type_header_code(h_types, h_code)
             h_code.putln("")
-            h_code.putln("#ifndef %s" % Naming.api_guard_prefix + self.api_name(env))
+            api_guard = Naming.api_guard_prefix + self.api_name(env)
+            h_code.putln("#ifndef %s" % api_guard)
             if h_vars:
                 h_code.putln("")
                 for entry in h_vars:
@@ -685,6 +687,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
         code.putln("#define _USE_MATH_DEFINES")
         code.putln("#endif")
         code.putln("#include <math.h>")
+        code.putln("#define %s" % Naming.h_guard_prefix + self.api_name(env))
         code.putln("#define %s" % Naming.api_guard_prefix + self.api_name(env))
         self.generate_includes(env, cimported_modules, code)
         code.putln("")
index 4d8bfa95c239b77b3dd93c32fe3fda067d24fa6d..710a7095444d8d5444fc2aa2d63f5c122d97233f 100644 (file)
@@ -19,3 +19,6 @@ cdef public void g(Blarg *x):
 
 cdef public api void h(Zax *x):
     pass
+
+cdef extern from "a_capi.h":
+    pass