help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error while building the devel branch: relocatable.c:31: error: expe


From: Eduardo A . Bustamante López
Subject: Re: Error while building the devel branch: relocatable.c:31: error: expected identifier or '(' at end of input
Date: Fri, 30 Aug 2024 01:13:57 -0700

On Thu, Aug 29, 2024 at 06:08:22PM +0300, Yuri Kanivetsky wrote:
> (...)
> Can you explain what exactly is happening here? Is it an issue with
> bash, fortify-headers or anything else? Judging from the `gcc -E`
> output it looks like preprocessed relocatable.c ends with
> __extension__, which is... an error? Is it because `#include_next
> <stdlib.h>` produces no output? Why?

The problem seems to be the inclusion order of system headers on Alpine Linux.
If "wchar.h" is included prior to "stdlib.h", the '#include_next' directive for
"stdlib.h" produces no output.

e.g.

    /bash # cat > foo.c
    #include <wchar.h>
    #include <stdlib.h>
    /bash # gcc -c -g3 -O0 foo.c
    foo.c:3: error: expected identifier or '(' at end of input

There is no error when the order is reversed:

    /bash # cat > bar.c
    #include <stdlib.h>
    #include <wchar.h>
    /bash # gcc -c -g3 -O0 bar.c
    /bash # echo $?
    0

The patch below fixes the build error for me. POSIX.1-2024 [1] says of wchar.h:

> Inclusion of the <wchar.h> header may make visible all symbols from the
> headers <ctype.h>, <string.h>, <stdarg.h>, <stddef.h>, <stdio.h>, <stdlib.h>,
> and <time.h>.

Though I don't know if this holds true for every system supported by Bash.

[1] <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/wchar.h.html>

/bash # PAGER= git diff -- config-bot.h
diff --git a/config-bot.h b/config-bot.h
index 07e910f1..2b23c3ed 100644
--- a/config-bot.h
+++ b/config-bot.h
@@ -134,6 +134,7 @@
    support user defined character classes.  */
 /* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.  */
 #if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H) && defined 
(HAVE_LOCALE_H)
+#  include <stdlib.h>
 #  include <wchar.h>
 #  include <wctype.h>
 #  if defined (HAVE_ISWCTYPE) && \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]