bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compile error with GNULIB_NAMESPACE on Solaris (stdio.h)


From: Bruno Haible
Subject: Re: Compile error with GNULIB_NAMESPACE on Solaris (stdio.h)
Date: Thu, 21 Nov 2019 11:53:18 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; )

Hi Christian,

> I got a compile error with Gnulib on Solaris 11 / gcc:
> 
> $ cat test.cc
> #define GNULIB_NAMESPACE gnulib
> #include "gnulib/config.h"
> #include "stdio.h"
> 
> $ g++ test.cc -I gnulib/import/ -I ../gnulib/import/
> gnulib/import/stdio.h:1717:1: error: ‘int vfprintf(std::FILE*, const
> char*, __va_list)’ conflicts with a previous declaration
>  _GL_CXXALIASWARN (vfprintf);
>  ^
> In file included from
> /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/stdio.h:75:0,
>                  from gnulib/import/stdio.h:43,
>                  from test.cc:3:
> /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/stdio_iso.h:223:12:
> note: previous declaration ‘int std::vfprintf(std::FILE*, const char*,
> __va_list)’
>  extern int vfprintf(FILE *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
>             ^
> In file included from /usr/include/sys/time.h:480:0,
>                  from gnulib/import/sys/time.h:39,
>                  from /usr/include/sys/select.h:28,
>                  from /usr/include/sys/types.h:664,
>                  from gnulib/import/sys/types.h:39,
>                  from gnulib/import/stdio.h:58,
>                  from test.cc:3:
> 
> And lots of other functions.

This should be fixed by the attached patches.

To investigate this,
- I created a testdir
  $ ./gnulib-tool --create-testdir --dir=/tmp/testdir --single-configure 
--with-c++-tests `./posix-modules`
- built it,
- ran
  $ make -k
- ran
  $ make -k 2>&1 | tee log4
and collected the resulting log files on various platforms.

A consequence of these patches is that _GL_CXXALIASWARN can only work
reliably on glibc platforms. On other platforms, I had to disable it
on 112 functions.


2019-11-21  Bruno Haible  <address@hidden>

        pthread-mutex: Fix errors in C++ mode.
        * m4/pthread-mutex.m4 (gl_PTHREAD_MUTEX): Test whether
        pthread_mutexattr_getrobust exists. If not, define
        PTHREAD_MUTEXATTR_ROBUST_UNIMPLEMENTED.
        * lib/pthread-mutex.c (pthread_mutexattr_getrobust,
        pthread_mutexattr_setrobust): Define also if <pthread.h> exists but
        PTHREAD_MUTEXATTR_ROBUST_UNIMPLEMENTED.
        * modules/pthread-mutex (configure.ac): Compile pthread-mutex.c also
        when <pthread.h> exists but pthread_mutexattr_getrobust needs a gnulib
        definition.

2019-11-21  Bruno Haible  <address@hidden>

        pthread-spin: Fix errors in C++ mode.
        * m4/pthread-spin.m4 (gl_PTHREAD_SPIN): Mark the pthread_spin_*
        functions as nonexistent when <pthread.h> exists but does not define
        the pthread_spinlock_t type.

2019-11-21  Bruno Haible  <address@hidden>

        math tests: Update after 2019-08-28 change.
        * tests/test-math-c++.cc (isfinite, isinf, isnan, signbit): Expect a
        return type of 'bool', not 'int'.

2019-11-21  Bruno Haible  <address@hidden>

        Fix various errors in _GL_CXXALIAS_SYS invocations.
        * lib/locale.in.h (freelocale): Use _GL_CXXALIAS_SYS_CAST instead of
        _GL_CXXALIAS_SYS.
        * lib/pthread.in.h (pthread_mutexattr_gettype,
        pthread_mutexattr_getrobust): Likewise.
        * lib/stdlib.in.h (srandom, initstate, setstate): Likewise.
        * lib/sys_socket.in.h (recv, send): Likewise.
        * lib/unistd.in.h (getdtablesize): Likewise.
        * lib/sys_select.in.h (select): In C++, write 'timeval' instead of
        'struct timeval'.

2019-11-21  Bruno Haible  <address@hidden>

        Disable many _GL_CXXALIASWARN on all platforms other than glibc systems.
        Reported by Christian Biesinger <address@hidden> in
        <https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00066.html>.
        * lib/fnmatch.in.h (fnmatch): Disable _GL_CXXALIASWARN invocation on
        non-glibc systems.
        * lib/locale.in.h (localeconv, setlocale): Likewise.
        * lib/math.in.h (cbrt, ceil, copysign, exp2, expm1, floor, fma, fmod,
        frexp, hypot, ilogb, log, log10, log1p, log2, logb, modf, remainder,
        rint, round, trunc): Likewise.
        * lib/monetary.in.h (strfmon_l): Likewise.
        * lib/pthread.in.h (pthread_mutexattr_getrobust,
        pthread_mutexattr_setrobust, pthread_mutex_lock, pthread_spin_init,
        pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock,
        pthread_spin_destroy): Likewise.
        * lib/signal.in.h (raise, signal): Likewise.
        * lib/stdio.in.h (fclose, fflush, fgetc, fgets, fopen, fprintf, fputc,
        fputs, fread, freopen, fscanf, fseek, ftell, fwrite, getc, getchar,
        perror, printf, putc, putchar, puts, remove, rename, scanf, sprintf,
        tmpfile, vfprintf, vprintf, vsprintf): Likewise.
        * lib/stdlib.in.h (calloc, malloc, mbtowc, realloc, strtod, wctomb):
        Likewise.
        * lib/string.in.h (memchr, strncat, strpbrk, strstr, strerror):
        Likewise.
        * lib/time.in.h (mktime, localtime, ctime, strftime): Likewise.
        * lib/wchar.in.h (btowc, wctob, mbsinit, mbrtowc, mbrlen, mbsrtowcs,
        wcrtomb, wcsrtombs, wmemchr, wmemcmp, wmemcpy, wmemmove, wmemset,
        wcslen, wcscpy, wcsncpy, wcscat, wcsncat, wcscmp, wcsncmp, wcscoll,
        wcsxfrm, wcschr, wcsrchr, wcscspn, wcsspn, wcspbrk, wcsstr, wcstok,
        wcsftime): Likewise.
        * lib/wctype.in.h (iswblank, wctrans, towctrans): Likewise.

Attachment: 0001-pthread-mutex-Fix-errors-in-C-mode.patch
Description: Text Data

Attachment: 0002-pthread-spin-Fix-errors-in-C-mode.patch
Description: Text Data

Attachment: 0003-math-tests-Update-after-2019-08-28-change.patch
Description: Text Data

Attachment: 0004-Fix-various-errors-in-_GL_CXXALIAS_SYS-invocations.patch
Description: Text Data

Attachment: 0005-Disable-many-_GL_CXXALIASWARN-on-all-platforms-other.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]