Thanks! That got me further, but still no luck. Any ideas on this one?
<snip>
opengl_wrap.cpp: In function `VALUE FXGLViewer_readPixels(FXGLViewer*, int,
int, int, int)':
opengl_wrap.cpp:688: `alloca' undeclared (first use this function)
opengl_wrap.cpp:688: (Each undeclared identifier is reported only once for
each
function it appears in.)
Hmmm... I wonder if this is an error in the Ruby header files? Here's the
offending line that it's trying to compile in FXRuby's opengl_wrap.cpp:
char *charBuffer = ALLOCA_N(char, size);
ALLOCA_N() is a macro defined in "ruby.h" as follows:
#define ALLOCA_N(type, n) (type *) alloca(sizeof(type)*(n))
and so when this macro is expanded it expects to have seen a declaration of
the C function alloca() somewhere earlier in the code. If you look a little
higher up in "ruby.h", before the definition of ALLOCA_N(), you'll see the
lines:
#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
#include <alloca.h>
#endif
and I believe that this is where the declaration of alloca() *should* come
into the picture. So it seems that the only reasons this wouldn't occur are:
1. If HAVE_ALLOCA_H isn't defined; or,
2. If HAVE_ALLOCA_H is defined, but __GNUC__ is too.
You can check the "config.h" header file for your Ruby installation (should
be in the same place as the "ruby.h" header file) to confirm that
HAVE_ALLOCA_H is defined; I'm pretty sure you'll find that it is. But since
you're compiling with GCC, the __GNUC__ symbol should also be declared (GCC
does this internally) and so we won't actually include <alloca.h> at this point.
This left me wondering where Ruby is expecting to find a declaration for
alloca() in this case. So I brought up the man page for alloca() [under
Linux] and learned that "... by default the glibc version of <stdlib.h>
includes <alloca.h> and that contains [a line that aliases alloca to a
built-in, inlined function]".
My initial guess, based on what you're seeing when trying to build the code
using GCC but under Solaris 2.x, is that Ruby's header file magic assumes
that since it has already included <stdlib.h> and you're compiling with GCC,
there's no need to include <alloca.h>. That is certainly true for Linux,
where we are indeed linking against the GNU C library, but I'm not sure if
it's also true for Solaris. In other words, it's possible that your code
gets linked against the Solaris C runtime library instead.
Were you waiting for a conclusion?
I don't have one (and that's why I'm Cc'ing this to the ML). I might
initially try changing those lines in "ruby.h" from this:
#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
#include <alloca.h>
#endif
to this:
#if defined(HAVE_ALLOCA_H)
#include <alloca.h>
#endif
which basically says, "if you've got an <alloca.h> header file, include it
unconditionally". Then try to pick up the compile of FXRuby where it left
off and see what happens.
Hope this gives you something to go on,
Lyle
···
On Thu, 07 Nov 2002 08:33:28 -0700, Daniel Berger <djberge@qwest.com> wrote :