[Pyrex] #if

Bryan Weingarten Bryan.Weingarten at watchguard.com
Fri Oct 17 18:39:16 CEST 2003


-----Original Message-----
From: Matthias Baas [mailto:baas at ira.uka.de] 
Sent: Friday, October 17, 2003 9:29 AM
To: pyrex at lists.copyleft.no
Subject: Re: [Pyrex] #if


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 -



hmmm.... i should have know better regarding the #.  but what you
suggest won't work for me since the _map_win32 function won't link since
it doesn't exist on non-windows platforms.  (what you suggest does work
in ctypes though because it handles late binding :)  i think i really
need the #if symantecs.  i thought someone said pyrex supported #if in a
previous posting... maybe i misread it.


bryan

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




More information about the Pyrex mailing list