[PATCH] Include string.h in elf-bfd.h
Saagar Jha
saagar@saagarjha.com
Wed Sep 23 07:01:15 GMT 2020
Hi Nick,
Sorry for the delay, I forgot to send the patch to the list ;) Here is an updated one that is largely based on your suggestions. Please let me know if it needs anything else.
Thanks,
Saagar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Include-string-headers-in-a-configure-test-for-GDB.patch
Type: application/octet-stream
Size: 1841 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20200923/05576801/attachment.obj>
-------------- next part --------------
> On Sep 14, 2020, at 02:55, Nick Clifton <nickc@redhat.com> wrote:
>
> 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
>
>
More information about the Binutils
mailing list