[PATCH] Include string.h in elf-bfd.h
Nick Clifton
nickc@redhat.com
Mon Sep 14 09:55:51 GMT 2020
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