[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fseeko, ftello: avoid inline function in include file
From: |
Bruno Haible |
Subject: |
fseeko, ftello: avoid inline function in include file |
Date: |
Mon, 13 Jun 2011 13:21:48 +0200 |
User-agent: |
KMail/1.9.9 |
Hi Eric,
Building gettext on Solaris 9, I'm seeing this link error:
cc -O -DHAVE_CONFIG_H -I. -I.. -DIN_GETTEXT_TOOLS_GNULIB_TESTS=1 -I. -I. -I..
-I./.. -I../gnulib-lib -I./../gnulib-lib -I../intl -D_REENTRANT
-I/home/haible/prefix-solaris9-sparc-cc/include -g -c -o
test-spawn-pipe-child.o test-spawn-pipe-child.c
/bin/bash ../libtool --tag=CC --preserve-dup-deps --mode=link cc -O -g
-o test-spawn-pipe-child test-spawn-pipe-child.o
libtool: link: cc -O -g -o test-spawn-pipe-child test-spawn-pipe-child.o
Undefined first referenced
symbol in file
rpl_ftello test-spawn-pipe-child.o
ld: fatal: Symbol referencing errors. No output written to test-spawn-pipe-child
*** Error code 1
The reason is that
- test-spawn-child must be linked against libc only.
- When it #includes <stdio.h>, it gets the stdio.h from gnulib.
- This header file defines an inline function rpl_ftell that references
rpl_ftello.
The fix is to move the inline function to non-inline code. Actually lib/ftell.c
already exists, with the right code.
The purpose of that inline function, as the comments say, is to ensure ftell()
is consistent with ftello(). But that can be achieved in a much simpler way:
through a dependency from module 'ftello' to module 'ftell'. Yes, that's a
circular dependency, but that is well supported by gnulib (even with
--conditional-dependencies).
Eric, you wrote this code on 2009-12-31 (committed on 2010-01-11), and I
reworked it on 2010-04-03. Any objections to this proposed patch (and likewise
for fseek and fseeko)? It fixes the problem on Solaris 9.
2011-06-13 Bruno Haible <address@hidden>
ftello: Provide a non-inline replacement of ftell().
* lib/stdio.in.h (ftell): Don't provide if module 'ftell' is not used.
* m4/ftell.m4 (gl_FUNC_FTELL): Replace ftell also if the system does
not have ftello() (such as on mingw).
* modules/ftello (Depends-on): Add ftell.
* modules/ftell (License): Change to LGPLv2+.
--- lib/stdio.in.h.orig Mon Jun 13 13:17:09 2011
+++ lib/stdio.in.h Mon Jun 13 13:14:01 2011
@@ -539,25 +520,6 @@
_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
# endif
_GL_CXXALIASWARN (ftello);
-# if (@REPLACE_FTELLO@ || address@hidden@) && address@hidden@
- /* Provide an ftell function that is consistent with ftello. */
- /* In order to avoid that ftell gets defined as a macro here, the
- developer can request the 'ftell' module. */
-# if !GNULIB_defined_ftell_function
-# undef ftell
-# define ftell rpl_ftell
-static inline long _GL_ARG_NONNULL ((1))
-rpl_ftell (FILE *f)
-{
-# if @REPLACE_FTELLO@
- return rpl_ftello (f);
-# else
- return ftello (f);
-# endif
-}
-# define GNULIB_defined_ftell_function 1
-# endif
-# endif
#elif defined GNULIB_POSIXCHECK
# define _GL_FTELL_WARN /* Category 1, above. */
# undef ftell
--- m4/ftell.m4.orig Mon Jun 13 13:17:09 2011
+++ m4/ftell.m4 Mon Jun 13 13:15:54 2011
@@ -1,4 +1,4 @@
-# ftell.m4 serial 2
+# ftell.m4 serial 3
dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,7 @@
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_FTELLO])
dnl When ftello needs fixes, ftell needs them too.
- if test $REPLACE_FTELLO != 0; then
+ if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then
REPLACE_FTELL=1
fi
])
--- modules/ftell.orig Mon Jun 13 13:17:09 2011
+++ modules/ftell Mon Jun 13 13:14:02 2011
@@ -23,7 +23,7 @@
<stdio.h>
License:
-LGPL
+LGPLv2+
Maintainer:
Bruno Haible
--- modules/ftello.orig Mon Jun 13 13:17:09 2011
+++ modules/ftello Mon Jun 13 13:14:02 2011
@@ -11,6 +11,8 @@
stdio
extensions
lseek [test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1]
+# Just to guarantee consistency between ftell() and ftello().
+ftell
configure.ac-early:
AC_REQUIRE([AC_FUNC_FSEEKO])
--
In memoriam Anna Göldi <http://en.wikipedia.org/wiki/Anna_Göldi>
- fseeko, ftello: avoid inline function in include file,
Bruno Haible <=