[Pyrex] Problems with 'public' C functions in an extension

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Mon Jul 3 04:39:58 UTC 2006


Hi again,

Stefan Behnel wrote:
> I'm running into a number of problems when trying to declare C functions
> public in a Pyrex extension module. The first problem is that the generated
> header file declares them /before/ all extension types, which lets the C
> compiler complain about undeclared struct's, as these types appear in the
> function arguments:
> 
> In file included from src/lxml/test.c:35:
> src/lxml/etree.h:6: warning: 'struct LxmlNodeBase' declared inside parameter list
> src/lxml/etree.h:6: warning: its scope is only this definition or declaration,
> which is probably not what you want
> 
> But even when I fix that by moving them to the end of the header file by hand,
> I can't manage to use them in an external module. The import fails with an
> unknown symbol (the function name).

Ok, according to the docs, this is supposed to work "without really being
tested". So it actually does not work.

Pyrex generates wrong C code for public C functions by declaring them
"extern". They are not "extern", as they are actually defined in the module,
right in the place where they are declared "extern", so this is wrong in
itself. A side effect then is the linking problem I'm witnessing.

Greg, I'd be glad if this could be fixed any time soon. I've been trying to
come up with a patch myself, but I couldn't find the place to patch so far. I
attached a partial patch that fixes the declaration, but it still does not
work for me. I'll keep looking around.

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: public-func.patch
Type: text/x-patch
Size: 1407 bytes
Desc: not available
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20060703/62a6a4a9/attachment.bin 


More information about the Pyrex mailing list