[Pyrex] #if

Michael P. Dubner dubnerm at mindless.com
Mon Oct 20 01:43:40 CEST 2003


Bryan Weingarten wrote:

> i'm sorry, but i need to ask a similar question.  is  _windows in the 
> example above defined in a c header file?   here's the line from the 
> documentation 

Of cause I mean:

def map_win32(self, err):
   #@if HostOS=="nt"
   return _wgpr._builtins._map_win32(err)
   #@endif

or one can define _windows using any of methods mentioned hereafter.

> defined
>    Pass any single identifier (except keywords) and by magic you will
>    get true if this identifier is defined (including as global
>    identifier) or not.
>
> i don't know what "global identifier" means in this context.  is it a 
> python global identifier, a pyrex global identifier a #define value in 
> some c header file?   the documentation uses the words like  "c-like 
> preprocessor",  "/nearly/ same meaning as in C preprocessor",  "Huge 
> difference from C preprocessor".  the one and only example uses 
> HostOS= "nt" which is really the python os.name variable not a c 
> #defined variable.   i'm just trying to understand.

As any preprocessor, discussioned one don't know about identifiers of 
host language (Pyrex). C headers parsed by c compiler, while this 
preprocessor
works _before_ pyrex parser (inside scanner), so it doesn't know about 
definitions in headers too.
Variables that preprocessor do knows about can be defined explicitly by 
#@define directive or passed using -D option for 'pyrexc' or 
--pyx-define options for 'setup.py build_ext'. Also there are couple of 
implicitly defined constants described on download page:
http://www.dubnerm.newmail.ru/soft/PyxPP/
Also I should mention that previous version has bug in implementation of 
#@define directive, so please download new one if you want to check it out:
http://www.dubnerm.newmail.ru/soft/PyxPP/PyxPP-0.9-2.tar.gz

-- 
Best regards,
Michael Dubner (dubnerm at mindless.com)
Brainbench MVP/HTML+JavaScript (http://www.brainbench.com)
PS: Sorry for my English







More information about the Pyrex mailing list