On Thu, 20 Jan 2005 21:22:58 +0100, Simon Strandgaard <neoneye / gmail.com> wrote:
> I am wrapping ncursesw for ruby.
> In ncurses.h it has declared the following variable:
> extern int COLORS;
> 
> I would like to access COLORS from ruby (if possible).
> I have tried extern 'int COLORS' but without luck.
> 
> shell> nm -a libncursesw.a
> [snip]
> 00000000 B COLOR_PAIRS
> 00000004 B COLORS
>          U curscr
>          U cur_term
> 0000001c t default_bg
> [snip]
> 
> I guess its accessable from the outside.. just how to do it?


I have made some more progress.. but still I cannot access the value..


  COLORS = symbol 'COLORS'
  Int = struct ["int value"]

...

Later I then can access Curses::COLORS which gives me an PtrData instance.
After I have invoked Curses.start_color I try access the variable.

  i = Curses::Int.new(Curses::COLORS).value
  p i

It results in 0.  Im not sure if this is the right way to access variables?




btw: wouldn't it be easier if one could type extern 'int COLORS' and
accomplish the same?


--
Simon Strandgaard