On Tue, Jan 26, 2010 at 6:30 PM, Torsten Mohr <[email protected]> wrote:
> Hello Tarek,
>
> great, good to know i can get some help here.
>
>> > I write a C++ extension module in which i need to tell if i compile on
>> > Linux or Windows. What is the preferred way to do this?
>>
>> What are you doing exactly with this information ?
>
> Basically what i try to do is write an extension module in C++ for Python.
> In the source code there are some parts for
> #ifdef HOST_MSWin32 and also for #ifdef HOST_linux.
>
> I already got an idea, as setup.py is normal pyhton code i could try os.name .
> That could help distinguishing in setup.py. But i'm not sure on how to
> forward this information so it is available in the source code.
> It could be also something like #ifdef HOST_posix or HOST_nt .
>
> What is the preferred way to make this information available to the compiler
> so i can use code like #ifdef HOST_posix?
>
> After looking in the documentation i found "define_macros", seems like the way
> to go, right?
Yes that's the way to pass values e.g. :
host = 'HOST_%s' % os.name
Extension('foo', .., define_macros=[(host, '1')])
But I wonder if there is no simple way for this particular need
(platform detection from within a C extension)
Tarek
_______________________________________________
Distutils-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/distutils-sig