From b5037005c624c03622c8c7dffac5d0fabbec7478 Mon Sep 17 00:00:00 2001 From: Lisandro Dalcin Date: Wed, 30 Mar 2011 20:09:36 -0300 Subject: [PATCH] guard C code from inclusion of gecompanion h api code --- Cython/Compiler/ModuleNode.py | 9 ++++++--- tests/compile/a_capi.pyx | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index a66d43b7..ae5c90bf 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -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 ") + 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("") diff --git a/tests/compile/a_capi.pyx b/tests/compile/a_capi.pyx index 4d8bfa95..710a7095 100644 --- a/tests/compile/a_capi.pyx +++ b/tests/compile/a_capi.pyx @@ -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 -- 2.26.2