[Radiance-general] Re: compiling rhdisp on Solaris with gcc?
Greg Ward
[email protected]
Sat, 29 Mar 2003 08:56:19 -0800
Lars Grobe < [email protected]> writes:
> While I am trying to get the solaris build ready, I have one problem
> here with
> Radiance 3.5, GCC 3.2.2 and Solaris 9: the function disp_wait in
> rhdisp.c gives
> me an error:
>
> gcc -I../common -L../lib -O3 -mcpu=v9 -mtune=v9 -m32 -DSPEED=200
> -ffast-math -Dlinux -L/usr/openwin/lib -I/usr/openwin/include
> -DNOSTEREO
> -DBIGMEM -c rhdisp.c
> rhdisp.c: In function `disp_wait':
> rhdisp.c:164: structure has no member named `_IO_read_end'
> rhdisp.c:164: structure has no member named `_IO_read_ptr'
> rhdisp.c:166: structure has no member named `_IO_read_end'
> rhdisp.c:166: structure has no member named `_IO_read_ptr'
> *** Error code 1
This is a nasty little bit of code that unfortunately is very difficult
to find a portable solution for. At the top of rhdisp.c there is a
macro called "fbufcnt(f)" that is supposed to return the number of
unread bytes in a FILE f's input buffer. There is no standard (or even
conventional) way to do this, so I have a few different hacks in there
that work on a few different systems. If this macro isn't operational,
rholo could lock up in interactive mode. The way around using such a
macro would be a lot of really ugly code, which is why I've done like
this.
The easist solution for solaris is to find the definition of the FILE
struct, which can be difficult to locate through the typical maze of
#ifdef's that proliferated since the inception of 3 or more so-called
"standard" UNIX's. I usually get the output of the C preprocessor and
scan it for the FILE struct that is brought in with stdio.h. I then
have to make an educated guess as to how the pointers in this struct
are used, and define the fbufcnt() macro accordingly. It's a real
tragedy they never standardized such a function, as it's invaluable for
operations involving multiple input streams.
-Greg