summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2022-05-15 14:23:11 -0400
committerguo <[email protected]>2022-05-16 10:02:22 +0800
commit19abf927d210338ea830908af7de37bb23d12682 (patch)
treedf74c4eb1fee1cae6dfee7cd3293fc6ff633edb7
parent2d418531242353fad21d6309704be5dc544c7d3e (diff)
[simulator] avoid conflicts between winsock.h and sys/time.h
-rw-r--r--bsp/simulator/drivers/SConscript6
-rw-r--r--components/libc/compilers/common/sys/ioctl.h4
-rw-r--r--components/libc/compilers/common/sys/select.h6
-rw-r--r--components/libc/compilers/common/sys/time.h4
4 files changed, 6 insertions, 14 deletions
diff --git a/bsp/simulator/drivers/SConscript b/bsp/simulator/drivers/SConscript
index ab6d4fdf56..e5d9b6ad08 100644
--- a/bsp/simulator/drivers/SConscript
+++ b/bsp/simulator/drivers/SConscript
@@ -17,12 +17,16 @@ if rtconfig.CROSS_TOOL == 'msvc':
'_CRT_DECLARE_NONSTDC_NAMES=0',
# errno macro redefinition
'_CRT_ERRNO_DEFINED',
- # time.h conflicts
+ # avoid time.h conflicts, such as struct timespec, ctime, difftime...
'_CRT_NO_TIME_T',
# disable deprecation of unsafe functions, such as strncpy
'_CRT_SECURE_NO_WARNINGS',
# RT_VESRION conflicts in winuser.h
'NORESOURCE',
+ # lean and mean for Windows.h, exclude winsock.h when include Windows.h
+ # avoid conlicts between sys/select.h, time.h, and winsock.h
+ # such as fd_set related, struct timeval...
+ 'WIN32_LEAN_AND_MEAN'
]
# remove no need file.
diff --git a/components/libc/compilers/common/sys/ioctl.h b/components/libc/compilers/common/sys/ioctl.h
index 0243932cba..4f9287304e 100644
--- a/components/libc/compilers/common/sys/ioctl.h
+++ b/components/libc/compilers/common/sys/ioctl.h
@@ -11,10 +11,6 @@
#ifndef __SYS_IOCTL_H__
#define __SYS_IOCTL_H__
-#ifdef _WIN32
-#include <winsock.h>
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/components/libc/compilers/common/sys/select.h b/components/libc/compilers/common/sys/select.h
index c939429279..1232edd6e8 100644
--- a/components/libc/compilers/common/sys/select.h
+++ b/components/libc/compilers/common/sys/select.h
@@ -16,10 +16,6 @@
#include <sys/types.h>
#include <sys/time.h>
-#ifdef _WIN32
-#include <winsock.h>
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -37,7 +33,6 @@ extern "C" {
typedef long fd_mask;
-#ifndef _WIN32
#ifndef _SYS_TYPES_FD_SET /* Newlib 2.2.0 or lower version */
#define NBBY 8 /* number of bits in a byte */
#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
@@ -57,7 +52,6 @@ typedef struct _types_fd_set {
#endif /* _SYS_TYPES_FD_SET */
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
-#endif /* _WIN32 */
#ifdef __cplusplus
}
diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h
index 69d85fe094..b7b193d25a 100644
--- a/components/libc/compilers/common/sys/time.h
+++ b/components/libc/compilers/common/sys/time.h
@@ -17,8 +17,6 @@
#include <stdint.h>
#include <time.h>
#ifdef _WIN32
-#include <winsock.h> /* for struct timeval */
-#include <corecrt.h> /* for __time64_t */
typedef __time64_t time_t;
#endif /* _WIN32 */
@@ -45,7 +43,7 @@ struct timezone
int tz_dsttime; /* type of dst correction */
};
-#if !defined(_TIMEVAL_DEFINED) && !defined(_WIN32)
+#if !defined(_TIMEVAL_DEFINED)
#define _TIMEVAL_DEFINED
struct timeval
{