sup-heliotrope / ncursesw-ruby

Ruby bindings to the ncursesw library (modified from: http://ncurses-ruby.berlios.de/)
GNU Lesser General Public License v2.1
22 stars 13 forks source link

Fails to compile on OS X #25

Closed xiongchiamiov closed 10 years ago

xiongchiamiov commented 10 years ago

I'm using a Macbook that's running 10.7, but has been through several OS upgrades, has many versions of Ruby installed, and generally has been hacked to bits and pieces over the last few years while getting software installed.

While attempting to install ncursesw (for sup), I get this error:

ncurses_wrap.c:861:21: error: variable has incomplete type 'struct timezone'
    struct timezone tz = {0,0};
                    ^

A search brings up the suggestion we need to #include <sys/time.h>, and indeed, this patch produces a successful compile:

diff --git a/ncurses_wrap.c b/ncurses_wrap.c
index af622c2..db3ac43 100644
--- a/ncurses_wrap.c
+++ b/ncurses_wrap.c
@@ -75,6 +75,8 @@
 #include <time.h>
 #endif

+#include <sys/time.h>
+
 VALUE mNcurses;  /* module Ncurses */
 VALUE cWINDOW;   /* class Ncurses::WINDOW */
 VALUE cSCREEN;   /* class Ncurses::SCREEN */

However, I don't really have any idea what I'm doing here. In particular, the #include <time.h> above makes me nervous.

gauteh commented 10 years ago

Thanks, according to: http://stackoverflow.com/questions/7889678/how-can-adding-a-header-increase-portability-sys-time-h this should increase portability. I include it if it is available.