[PATCH] Add startswith function and use it instead of CONST_STRNEQ.

Mike Frysinger vapier@gentoo.org
Mon Mar 22 06:57:55 GMT 2021

On 21 Mar 2021 23:42, Alan Modra via Binutils wrote:
> On Sat, Mar 20, 2021 at 12:58:10PM -0600, Tom Tromey wrote:
> > >>>>> "Alan" == Alan Modra via Binutils <binutils@sourceware.org> writes:
> > 
> > Alan> Forcing gdb to remove their startswith is a bit rude.
> > 
> > FWIW I think it would be fine, assuming it compiles, considering that
> > the functions have identical intended semantics.
> Yes, the following compiles.  Fortunately all gdb files that include
> gdbsupport/common-utils.h also include bfd.h by one means or another.
> Committed.
> bfd/
> 	* bfd-in.h (startswith): New inline.
> 	(CONST_STRNEQ): Use startswith.
> 	* bfd-in2.h: Regenerate.
> gdbsupport/
> 	* common-utils.h (startswith): Delete version now supplied by bfd.h.
> libctf/
> 	* ctf-impl.h: Include string.h.

putting this in the exported header is problematic.  as you see with the libctf
code, anyone including bfd.h now has to make sure string.h is included first
even if they don't use the header themselves.  this is generally considered bad
form for headers.

along those lines, a bunch of sim ports are broken now as they include bfd.h
but not all happen to include string.h first.

More information about the Binutils mailing list