I could do that and it make the compilation of libiberty passes. However, I have some other problem when using clang to build gdb because of libiberty.
Some c file from other component may include 'libiberty.h' which contains the following #if !HAVE_DECL_ASPRINTF /* Like sprintf but provides a pointer to malloc'd storage, which must be freed by the caller. */ extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2; #endif The HAVE_DECL_ASPRINTF is defined in config.h under libiberty directory. If the other c file only includes libiberty.h and does not include the libiberty/config.h and at the same time, _GNU_SOURCE is defind, the same error happens. On Mon, May 18, 2015 at 4:52 PM, Ian Lance Taylor <i...@google.com> wrote: > On Mon, May 18, 2015 at 4:26 PM, Yunlian Jiang <yunl...@google.com> wrote: >> >> Yes, the problem is libiberty is compiling some files >> with _GNU_SOURCE defined and some not. So the configure >> file does not include "#define _GNU_SOURCE". > > As far as I can see it should be fine to define _GNU_SOURCE when > compiling all libiberty files. > > Ian