From: Nick Clifton <nickc@redhat.com>
To: Saagar Jha <saagar@saagarjha.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] Include string.h in elf-bfd.h
Date: Mon, 14 Sep 2020 10:55:51 +0100 [thread overview]
Message-ID: <89121121-d196-f631-4b8a-df69eab42690@redhat.com> (raw)
In-Reply-To: <ABBC7BDA-E79C-4187-974D-F98FACDA751E@saagarjha.com>
Hi Saagar,
> Perhaps I’m doing it wrong, but I stuck #include “sysdep.h" at the top of that configure test and it didn’t seem to like it:
> In file included from conftest.c:171:
> ../bfd/sysdep.h:26:2: error: sysdep.h must be included in lieu of config.h
> #error sysdep.h must be included in lieu of config.h
Ah yes. For normal code "sysdep,h" is included and this will automatically
include "config.h" for you. But with configure tests a lot of the defines
that are provided by config.h are already set up. Like this:
> ../bfd/config.h:310:9: warning: 'PACKAGE' macro redefined [-Wmacro-redefined]
> conftest.c:26:9: note: previous definition is here
> #define PACKAGE "gdb"
So in order to include sysdep.h you must either stop configure from providing
all of these defines (probably not a good idea) or else undefine them before
including sysdep.h (also a bad idea) or...
> configure:16833: $? = 1
> configure: failed program was:
[...]
> | #define HAVE_STRING_H 1
> | #define HAVE_STRINGS_H 1
Give up on including sysdep.h, and instead copy the logic from that file that decides
which string header to include. IE:
#ifdef STRING_WITH_STRINGS
#include <string.h>
#include <strings.h>
#else
#ifdef HAVE_STRING_H
#include <string.h>
#else
#ifdef HAVE_STRINGS_H
#include <strings.h>
#else
extern char *strchr ();
extern char *strrchr ();
#endif
#endif
#endif
If you do this I would strongly urge you to add a comment as well, explaining that
the code has been copied from bfd/sysdep.h and that that header is not included
directly because it conflicts with the way that configure sets up its defines.
Cheers
Nick
next prev parent reply other threads:[~2020-09-14 9:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-06 2:36 Saagar Jha
2020-09-07 10:04 ` Nick Clifton
2020-09-08 22:23 ` Saagar Jha
2020-09-09 12:07 ` Nick Clifton
2020-09-11 5:57 ` Saagar Jha
2020-09-14 9:55 ` Nick Clifton [this message]
2020-09-23 7:01 ` Saagar Jha
2020-09-23 9:33 ` Nick Clifton
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=89121121-d196-f631-4b8a-df69eab42690@redhat.com \
--to=nickc@redhat.com \
--cc=binutils@sourceware.org \
--cc=saagar@saagarjha.com \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).