[Pyrex] #if

Bryan Weingarten bryan.weingarten at pobox.com
Mon Oct 20 08:01:19 CEST 2003


Michael P. Dubner wrote:

> 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
>

i really feel bad because i'm having the hardest time trying to make 
sense of this.   --pyx-define option that you mentioned for setup.py 
seems like it would fit my situation well, but i just can't find 
documentation on this.  even google comes up with no hits.  if i do use 
--pyx-define, then where and how do i use the defined variable in code?  
where is an example of this?  i checked the pyrex overview and guide but 
i didn't find it.

bryan





More information about the Pyrex mailing list