[Pyrex] #if

Matthias Baas baas at ira.uka.de
Fri Oct 17 18:29:27 CEST 2003


At 17:49 17.10.2003, Bryan Weingarten wrote:
>the following #if statement didn't appear the generated c code.  is
>there something i'm missing to make this work?
>
>def map_win32(self, err):
>     #if defined(_windows)
>     return _wgpr._builtins._map_win32(err)
>     #endif

Always keep in mind that you're writing *Pyrex* code, not *C* code. The C 
preprocessor isn't run on your file and in Pyrex the '#' symbol is the 
beginning of a comment, just as it is the case in Python. So you have to 
write your code more in a Python fashion:

import sys
...
def map_win32(self, err):
     if sys.platform=="win32":
         return _wgpr._builtins._map_win32(err)


- Matthias -





More information about the Pyrex mailing list