[PATCH] kconfig: fix implicit-int in check-lxdialog.sh

Arnold via busybox <[email protected]>
Newsgroups gmane.linux.busybox
Message-ID <CAPzoCoEn_VGsH9P1-eUsnGjstezqtQOzyXxHyYwEy7MOuD-q3A@mail.gmail.com>
Hello,

While building BusyBox (current master) on Arch Linux with a recent GCC
version, I encountered a failure when running make menuconfig. The build
reported that ncurses was missing, even though the headers and libraries
were correctly installed.

*The issue is caused by the test program in:*

scripts/kconfig/lxdialog/check-lxdialog.sh
which currently contains:

main() {}
Modern GCC versions reject implicit int return types and may treat them as
errors (e.g. -Werror=implicit-int). As a result, the test compilation
fails, and the script incorrectly reports that ncurses is missing.

*Replacing it with a standards-compliant definition fixes the issue:*

int main(void) { return 0; }
This change restores compatibility with newer GCC toolchains without
altering the detection logic.

Thanks.

Signed-off-by: Arnold <[email protected]>

_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox
0001-kconfig-fix-implicit-int-in-check-lxdialog.sh.patch (application/octet-stream, 4.7 KB)
From 5d673db2f1bd86fa5300bdf520da1dea8bba5906 Mon Sep 17 00:00:00 2001
From: Arnold <[email protected]>
Date: Wed, 11 Feb 2026 04:28:47 -0800
Subject: [PATCH] kconfig: fix implicit-int in check-lxdialog.sh

Modern GCC versions reject implicit int return types and may treat
them as errors (e.g. -Werror=implicit-int). The ncurses detection
test fails even when ncurses is installed.

Replace "main() {}" with
"int main(void) { return 0; }"
to restore compatibility with modern GCC.

Signed-off-by: Arnold <[email protected]>
---
 scripts/kconfig/lxdialog/check-lxdialog.sh | 124 ++++++++++-----------
 1 file changed, 61 insertions(+), 63 deletions(-)

diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
index 5075ebf..7197679 100755
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -2,41 +2,39 @@
 # Check ncurses compatibility
 
 # What library to link
-ldflags()
-{
-	pkg-config --libs ncursesw 2>/dev/null && exit
-	pkg-config --libs ncurses 2>/dev/null && exit
-	for ext in so a dll.a dylib ; do
-		for lib in ncursesw ncurses curses ; do
-			$cc -print-file-name=lib${lib}.${ext} | grep -q /
-			if [ $? -eq 0 ]; then
-				echo "-l${lib}"
-				exit
-			fi
-		done
-	done
-	exit 1
+ldflags() {
+  pkg-config --libs ncursesw 2>/dev/null && exit
+  pkg-config --libs ncurses 2>/dev/null && exit
+  for ext in so a dll.a dylib; do
+    for lib in ncursesw ncurses curses; do
+      $cc -print-file-name=lib${lib}.${ext} | grep -q /
+      if [ $? -eq 0 ]; then
+        echo "-l${lib}"
+        exit
+      fi
+    done
+  done
+  exit 1
 }
 
 # Where is ncurses.h?
-ccflags()
-{
-	if pkg-config --cflags ncursesw 2>/dev/null; then
-		echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1'
-	elif pkg-config --cflags ncurses 2>/dev/null; then
-		echo '-DCURSES_LOC="<ncurses.h>"'
-	elif [ -f /usr/include/ncursesw/curses.h ]; then
-		echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
-		echo ' -DNCURSES_WIDECHAR=1'
-	elif [ -f /usr/include/ncurses/ncurses.h ]; then
-		echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
-	elif [ -f /usr/include/ncurses/curses.h ]; then
-		echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
-	elif [ -f /usr/include/ncurses.h ]; then
-		echo '-DCURSES_LOC="<ncurses.h>"'
-	else
-		echo '-DCURSES_LOC="<curses.h>"'
-	fi
+ccflags() {
+  if pkg-config --cflags ncursesw 2>/dev/null; then
+    echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1'
+  elif pkg-config --cflags ncurses 2>/dev/null; then
+    echo '-DCURSES_LOC="<ncurses.h>"'
+  elif [ -f /usr/include/ncursesw/curses.h ]; then
+    echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
+    echo ' -DNCURSES_WIDECHAR=1'
+  elif [ -f /usr/include/ncurses/ncurses.h ]; then
+    echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
+  elif [ -f /usr/include/ncurses/curses.h ]; then
+    echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
+  elif [ -f /usr/include/ncurses.h ]; then
+    echo '-DCURSES_LOC="<ncurses.h>"'
+  else
+    echo '-DCURSES_LOC="<curses.h>"'
+  fi
 }
 
 # Temp file, try to clean up after us
@@ -45,47 +43,47 @@ trap "rm -f $tmp" 0 1 2 3 15
 
 # Check if we can link to ncurses
 check() {
-        $cc -x c - -o $tmp 2>/dev/null <<'EOF'
+  $cc -x c - -o $tmp 2>/dev/null <<'EOF'
 #include CURSES_LOC
-main() {}
+int main(void) { return 0; }
 EOF
-	if [ $? != 0 ]; then
-	    echo " *** Unable to find the ncurses libraries or the"       1>&2
-	    echo " *** required header files."                            1>&2
-	    echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
-	    echo " *** "                                                  1>&2
-	    echo " *** Install ncurses (ncurses-devel) and try again."    1>&2
-	    echo " *** "                                                  1>&2
-	    exit 1
-	fi
+  if [ $? != 0 ]; then
+    echo " *** Unable to find the ncurses libraries or the" 1>&2
+    echo " *** required header files." 1>&2
+    echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
+    echo " *** " 1>&2
+    echo " *** Install ncurses (ncurses-devel) and try again." 1>&2
+    echo " *** " 1>&2
+    exit 1
+  fi
 }
 
 usage() {
-	printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
+  printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
 }
 
 if [ $# -eq 0 ]; then
-	usage
-	exit 1
+  usage
+  exit 1
 fi
 
 cc=""
 case "$1" in
-	"-check")
-		shift
-		cc="$@"
-		check
-		;;
-	"-ccflags")
-		ccflags
-		;;
-	"-ldflags")
-		shift
-		cc="$@"
-		ldflags
-		;;
-	"*")
-		usage
-		exit 1
-		;;
+"-check")
+  shift
+  cc="$@"
+  check
+  ;;
+"-ccflags")
+  ccflags
+  ;;
+"-ldflags")
+  shift
+  cc="$@"
+  ldflags
+  ;;
+"*")
+  usage
+  exit 1
+  ;;
 esac
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.