From: Quintus Date: 2012-05-28T23:30:45+09:00 Subject: Re: [C exten] extconf.rg and #ifdef Am 28.05.2012 12:57, schrieb I��aki Baz Castillo: > 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. > What is wrong with the generic macros the compiler sets itself? If I remember correctly, every compiler targeting Windows sets a macro called _WIN32, and I bet there���s something similar for other systems. There shouldn���t be a need to manually define this in extconf.rb. Vale, Marvin -- Blog: http://pegasus-alpha.eu/blog ASCII-Ribbon-Kampagne () | ASCII Ribbon Campaign () - Stoppt HTML-E-Mail /\ | - Against HTML E-Mail /\ - Stoppt propriet��re Anh��nge | - Against proprietary attachments www.asciiribbon.org/index-de.html | www.asciiribbon.org