Pyrex Hard Case

Duncan Booth duncan at NOSPAMrcp.co.uk
Wed Apr 30 10:34:09 CEST 2003


Rodrigo Benenson <rodrigob at elo.utfsm.cl> wrote in
news:3EAD2D06.7010505 at elo.utfsm.cl: 

> I had allready done that. This command create an
> 
> extern MACRO_NAME(EXPECTED_ARGUMENTS)
> 
> Then macro name is remplaced by something like
> 
> extern double * C2F(stack).STK + x - 1 (EXPECTED_ARGUMENTS);
> 
> and the C compile is missed, this is the line I have comment via hand
> edit. 
> 
> rodrigob.
> 

I think you may need to cut this down to a minimal example that shows your 
problem and post it. Here is a minimal example that shows that how to use 
macros from Pyrex:

---- myhdr.h ----
#include <stdio.h>
#define PRINT(e) printf("%s", e)
---- test.pyx ----
cdef extern from "myhdr.h":
    void PRINT(char *EXPECTED_ARGUMENT)

def test(char *x):
    PRINT(x)
---- end ----

This compiles and from Python you can:

    import test
    test.test("Hello world")

which has the expected effect (printing the string).

N.B. You have to declare the variable types and return type when declaring 
the macro within Pyrex, otherwise it will try to pass Python objects as 
parameters and expect an object as a result.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?




More information about the Python-list mailing list