[#1094] Re: [ruby-cvs] ruby, ruby/lib: * eval.c (ev_const_defined, ev_const_get), variable.c — Dave Thomas <dave@...>

> * eval.c (rb_mod_autoload, rb_mod_autoload_p): new method;

12 messages 2003/05/29
[#1095] Re: [ruby-cvs] ruby, ruby/lib: * eval.c (ev_const_defined, ev_const_get), variable.c — nobu.nokada@... 2003/05/29

Hi,

[patch] "_FILE_OFFSET_BITS redefined" warning on Solaris

From: Johan Holmberg <holmberg@...>
Date: 2003-05-03 13:07:11 UTC
List: ruby-core #1011
Hi !

When I compiled Ruby on Solaris 2.8 today I noticed some strange
warnings, looking like:

     /home/holmberg/proj/ruby-1.8-via-CVS/ruby/config.h:2: \
         warning: `_FILE_OFFSET_BITS' redefined

This happens when compiling the following files:

	ext/curses/curses.c
	ext/digest/sha2/sha2.c
	ext/iconv/iconv.c
	ext/racc/cparse/cparse.c

I have tried to understand why this happens, and it seems to me that
the reason is that "ruby.h" is included too late when these files are
compiled (it is actually "config.h" that matters, but the modules of
Ruby use "ruby.h" that in its turn include "config.h").

If I'm not mistaken the symbol _FILE_OFFSET_BITS can be set by an
application to get access to 64-bit versions of certain file related
APIs. Ruby sets this symbol (via "configure"), and the setting is in
"config.h" ("#define _FILE_OFFSET_BITS 64" on my Solaris machine).

The system header files on Solaris act differently depending on whether
this symbol is set or not (and also set it to a default value if not
set).

So I guess it would be a good idea to have all source files of Ruby
set this variable the same way. This is accomplished in most files by
including "ruby.h" (and thereby "config.h") as one of the first
include files. But the files above fail to do so.

As far as I can understand moving the inclusion of "ruby.h" earlier
in these files can have no other negative impact. I tried this in my
local copy of the source and recomiled all of Ruby. The
_FILE_OFFSET_BITS warnings disappeared.

I append a patch below if you want to see what I did to the source.

/Johan Holmberg


Index: ext/curses/curses.c
===================================================================
RCS file: /src/ruby/ext/curses/curses.c,v
retrieving revision 1.17
diff -c -r1.17 curses.c
*** ext/curses/curses.c	26 Mar 2003 07:01:08 -0000	1.17
--- ext/curses/curses.c	3 May 2003 12:14:29 -0000
***************
*** 13,18 ****
--- 13,20 ----
   * - Takaaki Tateishi (ttate@kt.jaist.ac.jp)
   */

+ #include "ruby.h"
+
  #if defined(HAVE_NCURSES_H)
  # include <ncurses.h>
  #elif defined(HAVE_NCURSES_CURSES_H)
***************
*** 46,52 ****
  #endif

  #include <stdio.h>
- #include "ruby.h"
  #include "rubyio.h"

  static VALUE mCurses;
--- 48,53 ----
Index: ext/digest/sha2/sha2.c
===================================================================
RCS file: /src/ruby/ext/digest/sha2/sha2.c,v
retrieving revision 1.2
diff -c -r1.2 sha2.c
*** ext/digest/sha2/sha2.c	26 Feb 2002 22:07:36 -0000	1.2
--- ext/digest/sha2/sha2.c	3 May 2003 12:14:29 -0000
***************
*** 36,45 ****
  /* $RoughId: sha2.c,v 1.3 2002/02/26 22:03:36 knu Exp $ */
  /* $Id: sha2.c,v 1.2 2002/02/26 22:07:36 knu Exp $ */

  #include <stdio.h>
  #include <string.h>	/* memcpy()/memset() or bcopy()/bzero() */
  #include <assert.h>	/* assert() */
- #include "sha2.h"

  /*
   * ASSERT NOTE:
--- 36,45 ----
  /* $RoughId: sha2.c,v 1.3 2002/02/26 22:03:36 knu Exp $ */
  /* $Id: sha2.c,v 1.2 2002/02/26 22:07:36 knu Exp $ */

+ #include "sha2.h"
  #include <stdio.h>
  #include <string.h>	/* memcpy()/memset() or bcopy()/bzero() */
  #include <assert.h>	/* assert() */

  /*
   * ASSERT NOTE:
Index: ext/iconv/iconv.c
===================================================================
RCS file: /src/ruby/ext/iconv/iconv.c,v
retrieving revision 1.5
diff -c -r1.5 iconv.c
*** ext/iconv/iconv.c	20 Dec 2002 11:23:40 -0000	1.5
--- ext/iconv/iconv.c	3 May 2003 12:14:29 -0000
***************
*** 32,41 ****
  =end
  */

  #include <errno.h>
  #include <iconv.h>
  #include <assert.h>
- #include "ruby.h"
  #include "intern.h"

  /* Invalid value for iconv_t is -1 but 0 for VALUE, I hope VALUE is
--- 32,41 ----
  =end
  */

+ #include "ruby.h"
  #include <errno.h>
  #include <iconv.h>
  #include <assert.h>
  #include "intern.h"

  /* Invalid value for iconv_t is -1 but 0 for VALUE, I hope VALUE is
Index: ext/racc/cparse/cparse.c
===================================================================
RCS file: /src/ruby/ext/racc/cparse/cparse.c,v
retrieving revision 1.7
diff -c -r1.7 cparse.c
*** ext/racc/cparse/cparse.c	6 Aug 2002 23:42:04 -0000	1.7
--- ext/racc/cparse/cparse.c	3 May 2003 12:14:29 -0000
***************
*** 11,18 ****

  */

- #include <stdio.h>
  #include "ruby.h"


  /* -----------------------------------------------------------------------
--- 11,18 ----

  */

  #include "ruby.h"
+ #include <stdio.h>


  /* -----------------------------------------------------------------------


In This Thread

Prev Next