From: Robin Templeton <robin@igalia.com>
To: 32767@debbugs.gnu.org
Subject: bug#32767: glibc shadows gcc's C++ headers
Date: Tue, 18 Sep 2018 20:32:17 -0400 [thread overview]
Message-ID: <87efdquy26.fsf@terpri.org> (raw)
When compiling C++ programs, glibc's include directory takes precedence
over gcc's for standard C headers like math.h, but glibc's headers
aren't completely compatible with C++. For example, isnan from math.h is
supposed to be a function, but glibc defines it as a macro.
This program demonstrates the problem:
#include <math.h>
int main(void) { int isnan(0); return isnan; }
It works as expected when gcc's built-in C++ headers are used, but not
if glibc is installed:
% guix environment --pure --ad-hoc gcc -- g++ -E isnan.cpp | tail -n1
int main (void) { int isnan (0); return isnan; }
% guix environment --pure --ad-hoc gcc glibc -- g++ -E isnan.cpp | tail -n1
int main (void) { int __builtin_isnan (0); return isnan; }
As a temporary workaround, I'm using the following package as a
replacement for glibc, to keep the glibc headers out of $CPATH. If it's
installed along with gcc, ld-wrapper and binutils, the test program
compiles without errors.
(use-modules (guix) (gnu))
(use-package-modules base)
(package
(inherit glibc)
(name "my-glibc")
(arguments
(substitute-keyword-arguments (package-arguments glibc)
((#:phases phases)
`(modify-phases ,phases
(add-after 'install 'move-include
(lambda _
(rename-file (string-append %output "/include")
(string-append %output "/include-glibc"))
#t)))))))
next reply other threads:[~2018-09-19 1:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-19 0:32 Robin Templeton [this message]
2021-03-09 21:35 ` bug#32767: glibc shadows gcc's C++ headers Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87efdquy26.fsf@terpri.org \
--to=robin@igalia.com \
--cc=32767@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.