Menu

#72 patch to compile with gcc-14.1

v1.0 (example)
open
nobody
None
5
2024-05-02
2024-05-01
No

patch to compile with gcc-14.1

--- a/timezone.c        2004-11-13 08:35:12.000000000 +0000
+++ b/timezone.c        2024-05-01 09:22:13.780112533 +0000
@@ -39,6 +39,7 @@

 #include "zip.h"
 #include "timezone.h"
+#include <time.h>
 #include <ctype.h>
 #include <errno.h>

--- a/unix/configure    2008-06-20 03:32:20.000000000 +0000
+++ b/unix/configure    2024-05-01 09:27:12.149292690 +0000
@@ -509,17 +509,68 @@
 # Check for missing functions
 # add NO_'function_name' to flags if missing

-for func in rmdir strchr strrchr rename mktemp mktime mkstemp
-do
-  echo Check for $func
-  echo "int main(){ $func(); return 0; }" > conftest.c
-  $CC $BFLAG -o conftest conftest.c >/dev/null 2>/dev/null
-  [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $func | tr '[a-z]' '[A-Z]'`"
-done
+echo Check for rmdir
+cat > conftest.c << _EOF_
+#include <unistd.h>
+int main() { rmdir(""); return 0; }
+_EOF_
+$CC -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_RMDIR"
+
+echo Check for strchr
+cat > conftest.c << _EOF_
+#include <string.h>
+int main() { strchr("", 0); return 0; }
+_EOF_
+$CC -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_STRCHR"
+
+echo Check for strrchr
+cat > conftest.c << _EOF_
+#include <string.h>
+int main() { strrchr("",0); return 0; }
+_EOF_
+$CC -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_STRRCHR"
+
+echo Check for rename
+cat > conftest.c << _EOF_
+#include <stdio.h>
+int main() { rename("",""); return 0; }
+_EOF_
+$CC -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_RENAME"
+
+echo Check for mktemp
+cat > conftest.c << _EOF_
+#include <stdlib.h>
+int main() { mktemp(""); return 0; }
+_EOF_
+$CC -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_MKTEMP"
+
+echo Check for mktime
+cat > conftest.c << _EOF_
+#include <time.h>
+int main() { struct tm *t; mktime(t); return 0; }
+_EOF_
+$CC -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_MKTIME"
+
+echo Check for mkstemp
+cat > conftest.c << _EOF_
+#include <stdlib.h>
+int main() { mkstemp(""); return 0; }
+_EOF_
+$CC -o conftest conftest.c >/dev/null 2>/dev/null
+[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_MKSTEMP"


 echo Check for memset
-echo "int main(){ char k; memset(&k,0,0); return 0; }" > conftest.c
+cat > conftest.c << _EOF_
+#include <string.h>
+int main() { char k; memset(&k,0,0); return 0; }
+_EOF_
 $CC -o conftest conftest.c >/dev/null 2>/dev/null
 [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DZMEM"

@@ -544,7 +595,7 @@
 echo Check for errno declaration
 cat > conftest.c << _EOF_
 #include <errno.h>
-main()
+int main()
 {
   errno = 0;
   return 0;
@@ -556,6 +607,7 @@

 echo Check for directory libraries
 cat > conftest.c << _EOF_
+#include <dirent.h>
 int main() { return closedir(opendir(".")); }
 _EOF_

@@ -621,11 +673,13 @@

 echo Check for valloc
 cat > conftest.c << _EOF_
-main()
+#include <stdlib.h>
+int main()
 {
 #ifdef MMAP
     valloc();
 #endif
+    return 0;
 }
 _EOF_
 $CC ${CFLAGS} -c conftest.c > /dev/null 2>/dev/null

Discussion

  • Paul Marquess

    Paul Marquess - 2024-05-01

    What error did you get that meant that you had to add #include <time.h> to timezone.c?

     
    • Rudi Heitbaum

      Rudi Heitbaum - 2024-05-02

      Hi Paul,

      without time.h - this is the error:

      timezone.c: In function 'mktime':
      timezone.c:644:18: error: invalid use of undefined type 'struct tm'
        644 |   save_isdst = tm->tm_isdst;
            |                  ^~
      timezone.c:647:7: error: invalid use of undefined type 'struct tm'
        647 |     tm->tm_isdst = save_isdst;
            |       ^~
      timezone.c:661:11: error: implicit declaration of function 'localtime' [-Wimplicit-function-declaration]
        661 |     ltm = localtime(&then);
            |           ^~~~~~~~~
      timezone.c:44:1: note: 'localtime' is defined in header '<time.h>'; this is probably fixable by adding '#include <time.h>'
         43 | #include <errno.h>
        +++ |+#include <time.h>
         44 | 
      timezone.c:661:9: error: assignment to 'struct tm *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
        661 |     ltm = localtime(&then);
            |         ^
      timezone.c:670:7: error: invalid use of undefined type 'struct tm'
        670 |     tm->tm_isdst = save_isdst;
            |       ^~
      timezone.c:675:12: error: invalid use of undefined type 'struct tm'
        675 |     if (ltm->tm_isdst  && !save_isdst)
            |            ^~
      timezone.c:682:18: error: invalid use of undefined type 'struct tm'
        682 |     else if (!ltm->tm_isdst && save_isdst)
            |                  ^~
      timezone.c:689:8: error: invalid use of undefined type 'struct tm'
        689 |     ltm->tm_isdst = save_isdst;
            |        ^~
      timezone.c:693:11: error: invalid use of undefined type 'struct tm'
        693 |     *tm = *ltm;
            |           ^
      timezone.c:693:9: error: invalid use of undefined type 'struct tm'
        693 |     *tm = *ltm;
            |         ^
      timezone.c: In function 'mkgmtime':
      timezone.c:747:13: error: invalid use of undefined type 'struct tm'
        747 |   years = tm->tm_year + TM_YEAR_BASE;   /* year - 1900 -> year */
            |             ^~
      timezone.c:748:14: error: invalid use of undefined type 'struct tm'
        748 |   months = tm->tm_mon;                  /* 0..11 */
            |              ^~
      timezone.c:749:12: error: invalid use of undefined type 'struct tm'
        749 |   days = tm->tm_mday - 1;               /* 1..31 -> 0..30 */
            |            ^~
      timezone.c:750:13: error: invalid use of undefined type 'struct tm'
        750 |   hours = tm->tm_hour;                  /* 0..23 */
            |             ^~
      timezone.c:751:15: error: invalid use of undefined type 'struct tm'
        751 |   minutes = tm->tm_min;                 /* 0..59 */
            |               ^~
      timezone.c:752:15: error: invalid use of undefined type 'struct tm'
        752 |   seconds = tm->tm_sec;                 /* 0..61 in ANSI C. */
            |               ^~
      timezone.c:776:5: error: invalid use of undefined type 'struct tm'
        776 |   tm->tm_year = years - TM_YEAR_BASE;
            |     ^~
      timezone.c:777:5: error: invalid use of undefined type 'struct tm'
        777 |   tm->tm_mon = months;
            |     ^~
      timezone.c:778:5: error: invalid use of undefined type 'struct tm'
        778 |   tm->tm_mday = days + 1;
            |     ^~
      timezone.c:779:5: error: invalid use of undefined type 'struct tm'
        779 |   tm->tm_hour = hours;
            |     ^~
      timezone.c:780:5: error: invalid use of undefined type 'struct tm'
        780 |   tm->tm_min = minutes;
            |     ^~
      timezone.c:781:5: error: invalid use of undefined type 'struct tm'
        781 |   tm->tm_sec = seconds;
            |     ^~
      timezone.c:785:5: error: invalid use of undefined type 'struct tm'
        785 |   tm->tm_yday = days;
            |     ^~
      timezone.c:790:5: error: invalid use of undefined type 'struct tm'
        790 |   tm->tm_wday = ((unsigned)days + EPOCH_WDAY) % 7;
            |     ^~
      timezone.c:791:5: error: invalid use of undefined type 'struct tm'
        791 |   tm->tm_isdst = 0;
            |     ^~
      timezone.c:800:11: error: invalid use of undefined type 'struct tm'
        800 |        (tm->tm_yday > (YDAYS(TM_MON_MAX, TM_YEAR_MAX) + (TM_MDAY_MAX - 1)) ||
            |           ^~
      timezone.c:801:12: error: invalid use of undefined type 'struct tm'
        801 |         (tm->tm_yday == (YDAYS(TM_MON_MAX, TM_YEAR_MAX) + (TM_MDAY_MAX - 1)) &&
            |            ^~
      
       
      • Paul Marquess

        Paul Marquess - 2024-05-02

        Thanks

        Should have asked upfront, but what platform & C compiler are you running?

         
        • Rudi Heitbaum

          Rudi Heitbaum - 2024-05-02

          This is on the development branch of LibreELEC (version 13.0) (Linux 6.6.29) and with gcc-14.1rc. I will be updating the dev branch to gcc 14.1 once it is formally released,.

           
          • Paul Marquess

            Paul Marquess - 2024-05-02

            Ta. I'll wait for the official gcc 14.1 & see if I can reproduce the error

             
            👍
            1
  • Paul Marquess

    Paul Marquess - 2024-05-01

    Thanks Rudi. The changes to configure match ones we've already applied.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.