You are not logged in.

#1 2024-05-13 18:55:12

Mendenlama
Member
Registered: 2024-05-13
Posts: 2

[SOLVED]Another build errors with gcc14

Recently I tried to build some of the old curses tetris games from the AUR but observed that gcc gives error messages that were formerly not there. E.g.
https://aur.archlinux.org/packages/netris-git

snippets (in German locale setting)

[peter@arch netris]$ make
gcc  -g -O -c game.c
game.c: In Funktion »main«:
game.c:412:22: Fehler: Implizite Deklaration der Funktion »getopt«; meinten Sie »getsubopt«? [-Wimplicit-function-declaration]
  412 |         while ((ch = getopt(argc, argv, "hHRs:r:Fk:c:woDSCp:i:")) != -1)
      |                      ^~~~~~
      |                      getsubopt
make: *** [Makefile:28: game.o] Fehler 1
[peter@arch netris]$ 

Similar with vitetris: https://aur.archlinux.org/packages/vitetris:

netplay.c:20:8: Fehler: Rückgabetyp ist auf »int« voreingestellt [-Wimplicit-int]
   20 | static init_field(char *str, const char *val, int maxlen)
      |        ^~~~~~~~~~
make[2]: *** [Makefile:59: netplay.o] Fehler 1

My workaround was installing gcc13.
For vitetris:

CC=gcc-13 ./configure; make

For netris:

./Configure --cc gcc-13; make

Is there something that can be done with gcc14 without getting errors?

Last edited by Mendenlama (2024-05-13 21:47:27)

Offline

#2 2024-05-13 18:59:11

loqs
Member
Registered: 2014-03-06
Posts: 18,045

Re: [SOLVED]Another build errors with gcc14

A quick fix for gcc 14 might be:

CFLAGS+=' -Wno-error=implicit-function-declaration'

Though ideally you want to raise the issue with the upstream project as I would expect the source to be including all the needed headers which in this case I believe would be unistd.h or getopt.h.

Offline

#3 2024-05-13 19:02:04

gromit
Package Maintainer (PM)
From: Germany
Registered: 2024-02-10
Posts: 663
Website

Re: [SOLVED]Another build errors with gcc14

The first one is most likely just some missing include statement which you could submit upstream as a patch.
The second one looks a bit more complicated as I didn't even know that having an implicit return type is a thing in c, so you should also most likely open a bug report with the relevant upstream.

Offline

#4 2024-05-13 19:44:34

loqs
Member
Registered: 2014-03-06
Posts: 18,045

Re: [SOLVED]Another build errors with gcc14

For netris-git add the missing header <unistd.h> in game.c and add return type and return statement to a test program in Configure:

diff --git a/Configure b/Configure
index 9af1880..60a1e25 100755
--- a/Configure
+++ b/Configure
@@ -75,7 +75,7 @@ done
 CFLAGS="$COPT $CEXTRA"
 
 echo "Checking for libraries"
-echo 'main(){}' > test.c
+echo 'int main(void){return 0;}' > test.c
 LFLAGS=""
 for lib in -lcurses -lncurses; do
 	if $CC $CFLAGS $LEXTRA test.c $lib > /dev/null 2>&1; then
diff --git a/game.c b/game.c
index 9615846..1417cf8 100644
--- a/game.c
+++ b/game.c
@@ -26,6 +26,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <netinet/in.h>
+#include <unistd.h>
 
 int netType;
 char keyTable[KT_numKeys + 1];

Edit:
For vitetris add unspecified return type void for function init_field in src/menu/netplay.c and add missing include <time.h> in src/netw/tty_socket.c (not changed Makefile not using Arch's build flags):

diff --git a/src/menu/netplay.c b/src/menu/netplay.c
index 0b03ec7..f181ebb 100644
--- a/src/menu/netplay.c
+++ b/src/menu/netplay.c
@@ -17,7 +17,7 @@ static char name_str[18];
 
 static int cursor = -1;
 
-static init_field(char *str, const char *val, int maxlen)
+static void init_field(char *str, const char *val, int maxlen)
 {
 	memset(str, ' ', maxlen+1);
 	if (val) {
diff --git a/src/netw/tty_socket.c b/src/netw/tty_socket.c
index c6858a4..1593498 100644
--- a/src/netw/tty_socket.c
+++ b/src/netw/tty_socket.c
@@ -11,6 +11,7 @@
 #include <sys/un.h>
 #include <pwd.h>
 #include <errno.h>
+#include <time.h>
 #include "sock.h"
 #include "internal.h"
 

Last edited by loqs (2024-05-13 20:00:44)

Offline

#5 2024-05-13 20:35:09

Mendenlama
Member
Registered: 2024-05-13
Posts: 2

Re: [SOLVED]Another build errors with gcc14

Thanks for the input. These patches actually remove the error messages and both packages compile nicely. I will try to post them upstream. But looking at the github pages, I fear both projects look like abandoned. Maybe someone will take them up, who knows.

Offline

Board footer

Powered by FluxBB