From: Peter Zotov Date: 2012-05-28T20:53:09+09:00 Subject: Re: [C exten] extconf.rg and #ifdef Iñaki Baz Castillo писал 28.05.2012 14:57: > Hi, depending whether my Ruby C extension is being compiled on *nix > or > Windows, I need some #defines (i.e: OS_UNIX or OS_WIN). > > I see no way in MKMF documentation to generate a #define (based on > RbConfig["host_os"] for example). I've seen some "hacks" in > extconf.rb > like this: > > --------------------------------------- > def add_define(name) > $defs.push("-D#{name}") > end > > # If I'm on *nix: > add_define "OS_UNIX" > --------------------------------------- > > Is this the most ellegant way? any other solution? > > Thanks a lot. Yeah, that's pretty much how configure scripts work. (More complex ones like that from autoconf create config.h with the definitions, but you're unlikely to need this.) -- WBR, Peter Zotov.