Don't use defined() in C preprocessor macros

The ICC compiler doesn't seem to support defined() in macro expansion. Example
of warning:

warning #3199: "defined" is always false in a macro expansion in Microsoft mode
This commit is contained in:
Victor Stinner 2015-09-03 21:30:26 +02:00
parent 479fea63e1
commit 528a9ab1f0
1 changed files with 6 additions and 10 deletions

View File

@ -4781,9 +4781,7 @@ typedef struct {
} \ } \
#define UTIME_HAVE_DIR_FD (defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMENSAT)) #if defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMENSAT)
#if UTIME_HAVE_DIR_FD
static int static int
utime_dir_fd(utime_t *ut, int dir_fd, char *path, int follow_symlinks) utime_dir_fd(utime_t *ut, int dir_fd, char *path, int follow_symlinks)
@ -4806,9 +4804,7 @@ utime_dir_fd(utime_t *ut, int dir_fd, char *path, int follow_symlinks)
#endif #endif
#define UTIME_HAVE_FD (defined(HAVE_FUTIMES) || defined(HAVE_FUTIMENS)) #if defined(HAVE_FUTIMES) || defined(HAVE_FUTIMENS)
#if UTIME_HAVE_FD
static int static int
utime_fd(utime_t *ut, int fd) utime_fd(utime_t *ut, int fd)
@ -4912,14 +4908,14 @@ posix_utime(PyObject *self, PyObject *args, PyObject *kwargs)
memset(&path, 0, sizeof(path)); memset(&path, 0, sizeof(path));
path.function_name = "utime"; path.function_name = "utime";
memset(&utime, 0, sizeof(utime_t)); memset(&utime, 0, sizeof(utime_t));
#if UTIME_HAVE_FD #if defined(HAVE_FUTIMES) || defined(HAVE_FUTIMENS)
path.allow_fd = 1; path.allow_fd = 1;
#endif #endif
if (!PyArg_ParseTupleAndKeywords(args, kwargs, if (!PyArg_ParseTupleAndKeywords(args, kwargs,
"O&|O$OO&p:utime", keywords, "O&|O$OO&p:utime", keywords,
path_converter, &path, path_converter, &path,
&times, &ns, &times, &ns,
#if UTIME_HAVE_DIR_FD #if defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMENSAT)
dir_fd_converter, &dir_fd, dir_fd_converter, &dir_fd,
#else #else
dir_fd_unavailable, &dir_fd, dir_fd_unavailable, &dir_fd,
@ -5035,13 +5031,13 @@ posix_utime(PyObject *self, PyObject *args, PyObject *kwargs)
else else
#endif #endif
#if UTIME_HAVE_DIR_FD #if defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMENSAT)
if ((dir_fd != DEFAULT_DIR_FD) || (!follow_symlinks)) if ((dir_fd != DEFAULT_DIR_FD) || (!follow_symlinks))
result = utime_dir_fd(&utime, dir_fd, path.narrow, follow_symlinks); result = utime_dir_fd(&utime, dir_fd, path.narrow, follow_symlinks);
else else
#endif #endif
#if UTIME_HAVE_FD #if defined(HAVE_FUTIMES) || defined(HAVE_FUTIMENS)
if (path.fd != -1) if (path.fd != -1)
result = utime_fd(&utime, path.fd); result = utime_fd(&utime, path.fd);
else else