[compilers] Fix c/c++ compilation warnings and errors

This commit is contained in:
tyx 2022-04-02 16:21:45 +08:00 committed by guo
parent e896021b56
commit b80f581562
11 changed files with 68 additions and 3 deletions

View File

@ -13,6 +13,10 @@
#include <rtthread.h> #include <rtthread.h>
#ifdef __cplusplus
extern "C" {
#endif
enum enum
{ {
RT_WORK_STATE_PENDING = 0x0001, /* Work item pending state */ RT_WORK_STATE_PENDING = 0x0001, /* Work item pending state */
@ -70,7 +74,9 @@ rt_err_t rt_work_urgent(struct rt_work *work);
rt_err_t rt_work_cancel(struct rt_work *work); rt_err_t rt_work_cancel(struct rt_work *work);
#endif /* RT_USING_SYSTEM_WORKQUEUE */ #endif /* RT_USING_SYSTEM_WORKQUEUE */
#ifdef __cplusplus
}
#endif
#endif /* RT_USING_HEAP */ #endif /* RT_USING_HEAP */

View File

@ -43,6 +43,9 @@ struct part_flash_info
#elif defined (__GNUC__) /* GNU GCC Compiler */ #elif defined (__GNUC__) /* GNU GCC Compiler */
#define SECTION(x) __attribute__((section(x))) #define SECTION(x) __attribute__((section(x)))
#define USED __attribute__((used)) #define USED __attribute__((used))
#elif defined (_MSC_VER)
#define SECTION(x)
#define USED
#else #else
#error not supported tool chain #error not supported tool chain
#endif /* __CC_ARM */ #endif /* __CC_ARM */

View File

@ -875,7 +875,7 @@ static void fal(uint8_t argc, char **argv) {
result = fal_partition_read(part_dev, i, read_data, cur_op_size); result = fal_partition_read(part_dev, i, read_data, cur_op_size);
} }
/* data check */ /* data check */
for (int index = 0; index < cur_op_size; index ++) for (size_t index = 0; index < cur_op_size; index ++)
{ {
if (write_data[index] != read_data[index]) if (write_data[index] != read_data[index])
{ {

View File

@ -13,6 +13,10 @@
#include "sys/types.h" #include "sys/types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define O_RDONLY 00 #define O_RDONLY 00
#define O_WRONLY 01 #define O_WRONLY 01
#define O_RDWR 02 #define O_RDWR 02
@ -68,4 +72,8 @@ int open(const char *file, int flags, ...);
int fcntl(int fildes, int cmd, ...); int fcntl(int fildes, int cmd, ...);
int creat(const char *path, mode_t mode); int creat(const char *path, mode_t mode);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@ -20,6 +20,10 @@
#include <winsock.h> #include <winsock.h>
#endif #endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef FD_SETSIZE #ifndef FD_SETSIZE
#define FD_SETSIZE 32 #define FD_SETSIZE 32
#endif #endif
@ -55,4 +59,8 @@ typedef struct _types_fd_set {
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
#endif /* _WIN32 */ #endif /* _WIN32 */
#ifdef __cplusplus
}
#endif
#endif /* __SYS_SELECT_H__ */ #endif /* __SYS_SELECT_H__ */

View File

@ -14,6 +14,10 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#ifdef __cplusplus
extern "C" {
#endif
#define S_IFMT 00170000 #define S_IFMT 00170000
#define S_IFSOCK 0140000 #define S_IFSOCK 0140000
#define S_IFLNK 0120000 #define S_IFLNK 0120000
@ -80,4 +84,8 @@ int mknod(const char *, mode_t, dev_t);
int stat(const char *, struct stat *); int stat(const char *, struct stat *);
mode_t umask(mode_t); mode_t umask(mode_t);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@ -16,6 +16,10 @@
#include <stddef.h> #include <stddef.h>
#include <time.h> #include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef int32_t clockid_t; typedef int32_t clockid_t;
typedef int32_t key_t; /* Used for interprocess communication. */ typedef int32_t key_t; /* Used for interprocess communication. */
typedef int pid_t; /* Used for process IDs and process group IDs. */ typedef int pid_t; /* Used for process IDs and process group IDs. */
@ -39,4 +43,8 @@ typedef unsigned int u_int;
typedef unsigned char u_char; typedef unsigned char u_char;
typedef unsigned long u_long; typedef unsigned long u_long;
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@ -15,6 +15,10 @@
#include <stddef.h> #include <stddef.h>
#include "types.h" /* <sys/types.h> */ #include "types.h" /* <sys/types.h> */
#ifdef __cplusplus
extern "C" {
#endif
#define STDIN_FILENO 0 /* standard input file descriptor */ #define STDIN_FILENO 0 /* standard input file descriptor */
#define STDOUT_FILENO 1 /* standard output file descriptor */ #define STDOUT_FILENO 1 /* standard output file descriptor */
#define STDERR_FILENO 2 /* standard error file descriptor */ #define STDERR_FILENO 2 /* standard error file descriptor */
@ -46,4 +50,8 @@ uid_t geteuid(void);
gid_t getgid(void); gid_t getgid(void);
gid_t getegid(void); gid_t getegid(void);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_UNISTD_H */ #endif /* _SYS_UNISTD_H */

View File

@ -15,6 +15,10 @@
#include <winsock.h> #include <winsock.h>
#endif #endif
#ifdef __cplusplus
extern "C" {
#endif
struct winsize struct winsize
{ {
unsigned short ws_row; unsigned short ws_row;
@ -271,4 +275,8 @@ struct winsize
int ioctl(int fildes, int cmd, ...); int ioctl(int fildes, int cmd, ...);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@ -12,6 +12,10 @@
#include <stddef.h> #include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
struct statfs struct statfs
{ {
size_t f_bsize; /* block size */ size_t f_bsize; /* block size */
@ -22,4 +26,8 @@ struct statfs
int statfs(const char *path, struct statfs *buf); int statfs(const char *path, struct statfs *buf);
int fstatfs(int fd, struct statfs *buf); int fstatfs(int fd, struct statfs *buf);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@ -83,7 +83,7 @@ int var_export_init(void)
static char __vexp_strbuf1[1024]; static char __vexp_strbuf1[1024];
static char __vexp_strbuf2[1024]; static char __vexp_strbuf2[1024];
ve_exporter_t ve_exporter_temp; ve_exporter_t ve_exporter_temp;
int index_i, index_j; rt_size_t index_i, index_j;
/* past the three members in first ptr_begin */ /* past the three members in first ptr_begin */
ptr_begin += (sizeof(struct ve_exporter) / sizeof(unsigned int)); ptr_begin += (sizeof(struct ve_exporter) / sizeof(unsigned int));