From 9390581fa06a7147b54b2ebdf8f98c8713a84113 Mon Sep 17 00:00:00 2001 From: Dirinkbottle <2909128143@qq.com> Date: Sun, 16 Aug 2026 16:41:13 +0800 Subject: [PATCH 1/2] fix: fix build errors with newer GCC and resolve const qualifier mismatch with newer GCC --- bsp/abstract-machine/include/extra.h | 7 ++++--- components/libc/compilers/common/cstring.c | 4 ++-- components/libc/compilers/common/include/sys/time.h | 2 +- components/utilities/utest/utest.c | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/bsp/abstract-machine/include/extra.h b/bsp/abstract-machine/include/extra.h index 27c72f4a51ce..ecb454dfa377 100644 --- a/bsp/abstract-machine/include/extra.h +++ b/bsp/abstract-machine/include/extra.h @@ -1,5 +1,4 @@ -typedef long suseconds_t; -typedef unsigned long useconds_t; + #include #ifdef __ISA_NATIVE__ @@ -34,5 +33,7 @@ typedef unsigned long useconds_t; #define getcwd rt_getcwd #define gettimeofday rt_gettimeofday - +#else +typedef long suseconds_t; +typedef unsigned long useconds_t; #endif diff --git a/components/libc/compilers/common/cstring.c b/components/libc/compilers/common/cstring.c index 59c516d273e8..ff2dfaad26b9 100644 --- a/components/libc/compilers/common/cstring.c +++ b/components/libc/compilers/common/cstring.c @@ -48,12 +48,12 @@ void explicit_bzero(void* s, size_t n) char* index(const char* s, int c) { - return strchr(s, c); + return (char*)strchr(s, c); } char* rindex(const char* s, int c) { - return strrchr(s, c); + return (char*)strrchr(s, c); } int ffs(int i) diff --git a/components/libc/compilers/common/include/sys/time.h b/components/libc/compilers/common/include/sys/time.h index 87be959715e2..cba0bbc4c18f 100644 --- a/components/libc/compilers/common/include/sys/time.h +++ b/components/libc/compilers/common/include/sys/time.h @@ -48,7 +48,7 @@ struct timezone int tz_dsttime; /* type of dst correction */ }; -#ifndef _TIMEVAL_DEFINED +#if !defined (_TIMEVAL_DEFINED) &&!defined (__timeval_defined) #define _TIMEVAL_DEFINED struct timeval { diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index 3c91fa81667c..8cb7d625dd96 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -149,8 +149,8 @@ static const char *file_basename(const char *file) char *end_ptr = RT_NULL; char *rst = RT_NULL; - if (!((end_ptr = strrchr(file, '\\')) != RT_NULL || \ - (end_ptr = strrchr(file, '/')) != RT_NULL) || \ + if (!((end_ptr = (char*)strrchr(file, '\\')) != RT_NULL || \ + (end_ptr = (char*)strrchr(file, '/')) != RT_NULL) || \ (rt_strlen(file) < 2)) { rst = (char *)file; From 32d138b49cc78aac4ad9b3c99abd0e3d4229deac Mon Sep 17 00:00:00 2001 From: Dirinkbottle <2909128143@qq.com> Date: Sun, 16 Aug 2026 18:15:37 +0800 Subject: [PATCH 2/2] fix: fix build errors with newer GCC and resolve const qualifier mismatch with newer GCC --- bsp/abstract-machine/include/extra.h | 2 +- components/libc/compilers/common/cstdlib.c | 1 + components/libc/compilers/common/include/sys/select.h | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bsp/abstract-machine/include/extra.h b/bsp/abstract-machine/include/extra.h index ecb454dfa377..58ee47d35758 100644 --- a/bsp/abstract-machine/include/extra.h +++ b/bsp/abstract-machine/include/extra.h @@ -1,7 +1,7 @@ -#include #ifdef __ISA_NATIVE__ +#include // rename posix API to avoid conflict with glibc in native #define open rt_open #define creat rt_creat diff --git a/components/libc/compilers/common/cstdlib.c b/components/libc/compilers/common/cstdlib.c index 64bfbb10e0c0..8c947b7886e7 100644 --- a/components/libc/compilers/common/cstdlib.c +++ b/components/libc/compilers/common/cstdlib.c @@ -8,6 +8,7 @@ * 2021-02-15 Meco Man first version */ +#include #include #define DBG_TAG "stdlib" diff --git a/components/libc/compilers/common/include/sys/select.h b/components/libc/compilers/common/include/sys/select.h index 32ce39c287e2..71d7360f898d 100644 --- a/components/libc/compilers/common/include/sys/select.h +++ b/components/libc/compilers/common/include/sys/select.h @@ -14,7 +14,8 @@ #include #include -#include + +struct timeval; #ifdef __cplusplus extern "C" {