[Pyrex] cimport statement for external C functions

grahamc001uk grahamc001uk at yahoo.co.uk
Mon Feb 19 19:28:26 UTC 2007


OK, I worked out that I have to call it as interface.MyFunction() when using the cimport statement but I can leave out the "interface." when just putting the definitions at the top of the .pyx file.

It would be nice to have a simple literal include statement for including definitions so that their names can be put in the same module's name space.


----- Original Message ----
From: grahamc001uk <grahamc001uk at yahoo.co.uk>
To: pyrex at lists.copyleft.no
Sent: Monday, 19 February, 2007 7:16:50 PM
Subject: [Pyrex] cimport statement for external C functions

Has anybody successfully used the cimport statement for defining external C functions ?

If I put the following in file interface.pxd:
cdef extern from "interface.h":
    void MyFunction ()

and the following in my .pyx file:
cimport interface

with a call to MyFunction () later in the code.

The program compiles OK but I get the run time error:
NameError: MyFunction 
when I run it.

If I copy and paste the contents of the interface.pxd file into the .pyx file at the top and comment out the cimport statement then the program compiles OK and runs OK.

I am running on a windows platform (compiling with Microsoft VC7 v13.10.3077).

MyFunction is actually a stub function which just calls another function in a .DLL - buy surely this should make no difference.

















---




        
___________________________________________________________ 
All New Yahoo! Mail – Tired of unwanted email come-ons? Let our SpamGuard protect you. http://uk.docs.yahoo.com/nowyoucan.html

_______________________________________________
Pyrex mailing list
Pyrex at lists.copyleft.no
http://lists.copyleft.no/mailman/listinfo/pyrex





		
___________________________________________________________ 
What kind of emailer are you? Find out today - get a free analysis of your email personality. Take the quiz at the Yahoo! Mail Championship. 
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk 



More information about the Pyrex mailing list