This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Older GCC versions and non-GNU compilers are still supported when compiling programs that use the GNU C Library. (We do not know exactly how old, and some GNU extensions to C may be _de facto_ required. If you are interested in helping us make this statement less vague, please contact libc-alpha@sourceware.org.)
Environment
-----------
Test program compiled on Artful Aardvark Ubuntu 17.10.
$ which g++-4.8
/usr/bin/g++-4.8
$ /usr/bin/g++-4.8 --version
g++-4.8 (Ubuntu 4.8.5-4ubuntu6) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ which g++-4.9
/usr/bin/g++-4.9
$ /usr/bin/g++-4.9 --version
g++-4.9 (Ubuntu 4.9.4-2ubuntu1) 4.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ which g++-5
/usr/bin/g++-5
$ /usr/bin/g++-5 --version
g++-5 (Ubuntu 5.5.0-1ubuntu1) 5.4.1 20171010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ which g++-6
/usr/bin/g++-6
$ /usr/bin/g++-6 --version
g++-6 (Ubuntu 6.4.0-8ubuntu1) 6.4.0 20171010
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ which g++-7
/usr/bin/g++-7
$ /usr/bin/g++-7 --version
g++-7 (Ubuntu 7.2.0-8ubuntu3) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ dpkg --status libc6-dev:amd64
Package: libc6-dev
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 18041
Maintainer: Ubuntu Developers <ubuntu-
Architecture: amd64
Multi-Arch: same
Source: glibc
Version: 2.26-0ubuntu2
Provides: libc-dev
Depends: libc6 (= 2.26-0ubuntu2), libc-dev-bin (= 2.26-0ubuntu2), linux-libc-dev (>= 4.13.0)
Suggests: glibc-doc, manpages-dev
Breaks: binutils (<< 2.26), binutils-gold (<< 2.20.1-11),
cmake (<< 2.8.4+dfsg.1-5), gcc-4.4 (<< 4.4.6-4), gcc-4.5
(<< 4.5.3-2), gcc-4.6 (<< 4.6.0-12), libhwloc-dev (<<
1.2-3), libjna-java (<< 3.2.7-4), liblouis-dev (<< 2.3.0-2),
liblouisxml-dev (<< 2.4.0-2), make (<< 3.81-8.1),
pkg-config (<< 0.26-1)
Conflicts: libc0.1-dev, libc0.3-dev, libc6.1-dev
Description: GNU C Library: Development Libraries and Header Files
Contains the symlinks, headers, and object files needed to compile
and link programs which use the standard C library.
Homepage: http://
Original-
Test cases that fail
-------
$ g++-5 -x c++ - <<EOF
#include <math.h>
int main()
{
return signbit(1.0);
}
EOF
In file included from <stdin>:1:0:
<stdin>: In function ‘int main()’:
<stdin>:4:10: error: expected primary-_expression_ before ‘__typeof’
<stdin>:4:10: error: expected primary-_expression_ before ‘float’
<stdin>:4:10: error: ‘__builtin_
<stdin>:4:10: error: expected primary-_expression_ before ‘__typeof’
<stdin>:4:10: error: expected primary-_expression_ before ‘double’
<stdin>:4:10: error: expected primary-_expression_ before ‘__typeof’
<stdin>:4:10: error: expected primary-_expression_ before ‘long’
<stdin>:4:10: error: ‘__builtin_
<stdin>:4:10: error: ‘__builtin_
<stdin>:4:10: error: redeclaration of ‘<typeprefixerr
<stdin>:4:10: note: previous declaration ‘<typeprefixerr
<stdin>:4:10: error: ‘__builtin_
<stdin>:4:10: error: redeclaration of ‘<typeprefixerr
<stdin>:4:10: note: previous declaration ‘<typeprefixerr
$ g++-4.9 -x c++ - <<EOF
#include <math.h>
int main()
{
return signbit(1.0);
}
EOF
In file included from <stdin>:1:0:
<stdin>: In function ‘int main()’:
<stdin>:4:10: error: expected primary-_expression_ before ‘__typeof’
<stdin>:4:10: error: expected primary-_expression_ before ‘float’
<stdin>:4:10: error: ‘__builtin_
<stdin>:4:10: error: expected primary-_expression_ before ‘__typeof’
<stdin>:4:10: error: expected primary-_expression_ before ‘double’
<stdin>:4:10: error: expected primary-_expression_ before ‘__typeof’
<stdin>:4:10: error: expected primary-_expression_ before ‘long’
<stdin>:4:10: error: ‘__builtin_
<stdin>:4:10: error: ‘__builtin_
<stdin>:4:10: error: redeclaration of ‘<typeprefixerr
<stdin>:4:10: note: previous declaration ‘<typeprefixerr
<stdin>:4:10: error: ‘__builtin_
<stdin>:4:10: error: redeclaration of ‘<typeprefixerr
<stdin>:4:10: note: previous declaration ‘<typeprefixerr
$ g++-4.8 -x c++ - <<EOF
#include <math.h>
int main()
{
return signbit(1.0);
}
EOF
In file included from <stdin>:1:0:
<stdin>: In function ‘int main()’:
<stdin>:4:10: error: expected primary-_expression_ before ‘__typeof’
<stdin>:4:10: error: expected primary-_expression_ before ‘float’
<stdin>:4:10: error: ‘__builtin_
<stdin>:4:10: error: expected primary-_expression_ before ‘__typeof’
<stdin>:4:10: error: expected primary-_expression_ before ‘double’
<stdin>:4:10: error: expected primary-_expression_ before ‘__typeof’
<stdin>:4:10: error: expected primary-_expression_ before ‘long’
<stdin>:4:10: error: ‘__builtin_
<stdin>:4:10: error: ‘__builtin_
<stdin>:4:10: error: redeclaration of ‘<typeprefixerr
<stdin>:4:10: note: previous declaration ‘<typeprefixerr
<stdin>:4:10: error: ‘__builtin_
<stdin>:4:10: error: redeclaration of ‘<typeprefixerr
<stdin>:4:10: note: previous declaration ‘<typeprefixerr
Test cases that succeed
-------
$ g++-6 -x c++ - <<EOF
#include <math.h>
int main()
{
return signbit(1.0);
}
EOF
$ g++-7 -x c++ - <<EOF
#include <math.h>
int main()
{
return signbit(1.0);
}
EOF
Expected result
---------------
Successful compile and return 0.
Supposed cause
--------------
The definition of function-like macro __MATH_TG at
lines 343-74 of /usr/include/math.h
requires some finesse to handle C++ programs.
As noted in
gcc.gnu.org, "6.59 Other Built-in Functions Provided by GCC"
Available: https:/
Accessed: 22 October 2017
the built-in functions __builtin_
are only available in C.
Workaround
----------
Hack /usr/include/math.h and modify line 346
#elif __HAVE_
to read
#elif __HAVE_
This clearly doesn't cover all the cases but you get the picture.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |